[VBS-] 檔案移到資料夾

作者: unfinish (百年孤寂)   2014-06-24 15:48:23
下面這段程式在VBA底下可以正常執行
存成.vbs之後 執行時沒有異常訊息
但是也沒有任何執行效果
沒有移動任何檔案甚至連建立新的資料夾都沒有
有人可以告訴我是出了什麼問題嗎
謝謝大家
Sub FileSeparator()
Dim FSO, MyFiles
Dim DateLastModified, FileName, FolderPath
Dim FileInfo
FolderPath = "D:\TEST"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set MyFiles = FSO.getfolder(FolderPath)
For Each FileInfo In MyFiles.Files
FileName = FileInfo.Name
DateLastModified = Format(FileInfo.DateLastModified, "YYMMDD")
If Not FSO.FolderExists(FolderPath & "\" & DateLastModified) Then
FSO.CreateFolder (FolderPath & "\" & DateLastModified)
End If
FSO.MoveFile FolderPath & "\" & FileName, FolderPath & "\
" & DateLastModified & "\"
Next
End Sub

Links booklink

Contact Us: admin [ a t ] ucptt.com