所以我需要一些帮助,我还是 vbscript 的新手。我有一个包含 100 多个不同类型文件的目录,但只想将具有正确时间戳的文件移动到另一个目录。
文件的命名约定如下:stuff-11012013-042567.txt,我只想移动具有匹配时间戳的文件。
我已经按如下方式启动了我的脚本,但我坚持如何查找和匹配文件名中的特定字符串,我是否必须将匹配结果设置为变量才能一次移动所有文件?
'Create file object system and declare to variable
Set objFSO=CreateObject("Scripting.FileSystemObject")
'Get source and destination folders, set source and destination folder paths to variables
Set sfldr=objFSO.getFolder("in")
Set dfldr=objFSO.getFolder("out")
'Check to see if source folder Exists
If objFSO.FolderExists("in\") Then
'Check to see if there are existing files on destination folder
If dFldr.files.count = 0 Then
If sfldr.files.count < 6 then
msgbox("Need more files!")
ElseIf sfldr.files.count > 6 then
msgbox("Too many files, please double check for consistency")
Else
'Enter loop to move all files from source directory to destination directory
for each file in sfldr.files
objFSO.MoveFile "in\*", "out"
Next
End If
Else
msgbox("Files already Exists on Destination Folder. Please Check files!")
End If
Else
msgbox("Source path does not exist")
End If