基于文件名VBscript中的匹配时间戳移动文件

基于文件名VBscript中的匹配时间戳移动文件,vbscript,Vbscript,所以我需要一些帮助,我还是vbscript新手。我有一个目录,其中包含100多个不同类型的文件,但我只想将具有正确时间戳的文件移动到另一个目录 文件的命名约定如下:stuff-11012013-042567.txt,我只想移动具有匹配时间戳的文件 我已经按照如下方式开始了我的脚本,但我一直坚持如何查找和匹配文件名中的特定字符串,我是否必须将匹配结果设置为变量才能一次移动所有文件 'Create file object system and declare to variable Set obj

所以我需要一些帮助,我还是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
“创建文件对象系统并声明为变量”
设置objFSO=CreateObject(“Scripting.FileSystemObject”)
'获取源文件夹和目标文件夹,将源文件夹和目标文件夹路径设置为变量
设置sfldr=objFSO.getFolder(“in”)
设置dfldr=objFSO.getFolder(“out”)
'检查源文件夹是否存在
如果objFSO.FolderExists(“in\”),则
'检查目标文件夹中是否存在现有文件
如果dFldr.files.count=0,则
如果sfldr.files.count<6,则
msgbox(“需要更多文件!”)
ElseIf sfldr.files.count>6然后
msgbox(“文件太多,请仔细检查一致性”)
其他的
'输入loop将所有文件从源目录移动到目标目录
对于sfldr.files中的每个文件
objFSO.MoveFile“in\*”和“out”
下一个
如果结束
其他的
msgbox(“目标文件夹中已存在文件。请检查文件!”)
如果结束
其他的
msgbox(“源路径不存在”)
如果结束

For
循环中,您需要检查每个文件的名称并决定如何处理它

如果时间戳在文件名中始终处于相同位置,则可以使用
Mid()
函数。如果位置不同,可以使用
Instr()