Function ShowFileList(folderspec)
Dim fso, f, f1,f2,v1,fc, s ,N ,s1 ,s2 ,s3
Set fso = CreateObject("scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("filename.txt", True)
N = 0
For Each f1 in fc
N = N + 1
s1 = s& f1.name
f2= mid(f1.name,instr(f1.name,"号")+1)
MyFile.WriteLine(f1.name)
s2 = "第 "&N&" 个:"&s1&vbCrLf
s3 = s3+s2
Next
ShowFileList = "该文件夹中总共 "&N&" 个文件:"&vbCrLf&s3&vbcrlf
End Function
Set ws=WScript.CreateObject("wscript.shell")
w=ws.CurrentDirectory
wenjian=ShowFileList(w)
MsgBox wenjian
网友评论