遍历处理path及其子目录所有文件
'遍歷處理path及其子目錄所有文件
Sub ShowAllFile(Path)
??? Set FSO = CreateObject("Scripting.FileSystemObject")
??? Set f = FSO.GetFolder(Path)
??? Set fc2 = f.files
??? For Each myfile in fc2
???????? WScript.Echo path&"\"&myfile.name?????
??? Next
??? Set fc = f.SubFolders
??? For Each f1 in fc
??????? ShowAllFile path&"\"&f1.name
??????? Next
??? Set FSO = Nothing
End Sub
?
遍歷所有folder_中的txt文件
'根目錄
Set fso=createobject("scripting.filesystemobject")
set folder_=fso.getfolder(folder_)
set files=folder_.files
for each file in files
?ext=mid(file,InStrRev(file, ".")+1)
?ext=lcase(ext)
?if ext="txt" then
??MsgBox(file)
?end if
next
'根目錄+子目錄
sub scan(folder_)
Set fso=createobject("scripting.filesystemobject")
set folder_=fso.getfolder(folder_)
set files=folder_.files
for each file in files
?ext=mid(file,InStrRev(file, ".")+1)
?ext=lcase(ext)
?if ext="txt" then
??all_file=all_file+file+"? "
?end if
next
set subfolders=folder_.subfolders
for each subfolder in subfolders
?scan(subfolder)
next
end sub
all_file=""
scan("E:\shi")
WScript.Echo all_file
總結(jié)
以上是生活随笔為你收集整理的遍历处理path及其子目录所有文件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php libiconv close_P
- 下一篇: 穿越回二年级讲CPU工作原理。