On Error Resume Next set Wshshell = WScript.CreateObject("WScript.Shell") strFolder = "d:\image" saveFile = strFolder & "\FileList.txt" ForWriting = 2 Set objShell = CreateObject ("Shell.Application") Set objFolder = objShell.Namespace(strFolder) For Each objItem in objFolder.Items If objItem.isFolder Then strFolds = strFolds & "[" & objItem.Name & "]" & vbCrLf Else Wshshell.Run "D:\ffmpeg-20170827-ef0c6d9-win64-static\bin\ffmpeg.exe " & "-i " & strFolder & "\" & objItem.Name & " -vcodec h264 " & objItem.Name & ".mp4" strFiles = strFiles & objItem.Name & vbCrLf End If Next strLists = strFolds & vbCrLf & strFiles Set fs = CreateObject (Scripting.FileSystemObject) Set ts = fs.OpenTextFile (saveFile, ForWriting, True) ts.Write strLists: ts.Close Set WshShell=Nothing WScript.Quit