OptionExplicit
DimobjFso,objSrcFls,strSrcFld,objFile,objDstFile,strDstFile
strSrcFld="e:\download\""原始檔夾,請自行更改
strDstFile="e:\vbs\FileLists.txt""輸出的目標檔案,請自行更改
SetobjFso=CreateObject("Scripting.FileSystemObject")
SetobjDstFile=objFso.OpenTextFile(strDstFile,2,True)
SetobjSrcFls=objFso.GetFolder(strSrcFld).Files
ForEachobjFileInobjSrcFls
objDstFile.WriteLinestrSrcFld&objFile.Name
Next
DimobjFld,objSrcFld
SetobjSrcFld=objFso.GetFolder(strSrcFld).SubFolders
ForEachobjFldInobjSrcFld
CallLoopSubFlds(strSrcFld&objFld.Name&"\")
objDstFile.Close
SetobjFile=Nothing
SetobjSrcFls=Nothing
SetobjFso=Nothing
SubLoopSubFlds(strFld)
ForEachobjFileInobjFso.GetFolder(strFld).Files
objDstFile.WriteLinestrFld&objFile.Name
ForEachobjFldInobjFso.GetFolder(strFld).SubFolders
CallLoopSubFlds(strFld&objFld.Name&"\")
EndSub
OptionExplicit
DimobjFso,objSrcFls,strSrcFld,objFile,objDstFile,strDstFile
strSrcFld="e:\download\""原始檔夾,請自行更改
strDstFile="e:\vbs\FileLists.txt""輸出的目標檔案,請自行更改
SetobjFso=CreateObject("Scripting.FileSystemObject")
SetobjDstFile=objFso.OpenTextFile(strDstFile,2,True)
SetobjSrcFls=objFso.GetFolder(strSrcFld).Files
ForEachobjFileInobjSrcFls
objDstFile.WriteLinestrSrcFld&objFile.Name
Next
DimobjFld,objSrcFld
SetobjSrcFld=objFso.GetFolder(strSrcFld).SubFolders
ForEachobjFldInobjSrcFld
CallLoopSubFlds(strSrcFld&objFld.Name&"\")
Next
objDstFile.Close
SetobjFile=Nothing
SetobjSrcFls=Nothing
SetobjFso=Nothing
SubLoopSubFlds(strFld)
ForEachobjFileInobjFso.GetFolder(strFld).Files
objDstFile.WriteLinestrFld&objFile.Name
Next
ForEachobjFldInobjFso.GetFolder(strFld).SubFolders
CallLoopSubFlds(strFld&objFld.Name&"\")
Next
EndSub