我正在使用VBS中的备份脚本创建一个文件夹,然后将powerpoint文件复制到最近创建的文件夹中。
除了底部的MoveFile命令外,一切都很好 这是我到目前为止所得到的(底部代码是最重要的,但只是让每个人都能理解我来自哪里):
sourceDir = "T:\Team"
destinationDir = "T:\Team\Archive\Archive"
const OverwriteExisting = True
intNum = 1
strDirectory = destinationDir & "_" & replace(date,"/",".") & "_" & intNum
'This checks if the folder exists and if not it will create a folder with the date and increment the folder name incase there are multiple updates in a single day.
if not filesys.FolderExists(destinationDir) then
While filesys.FolderExists(destinationDir & "_" & replace(date,"/",".") & "_" & intNum) = True
intNum = intNum + 1
Wend
Set archivefolder = filesys.CreateFolder(destinationDir & "_" & replace(date,"/",".") & "_" & intNum)
Else
Set archivefolder = filesys.CreateFolder(destinationDir)
Set objFolder = fso.CreateFolder(strDirectory)
End if
Dim thisday, thisdayy, thisdayyy
Today_Date()
' This is the problem code
filesys.MoveFile "T:\Arriva\Project_Organigram_" & thisday & "." & thisdayy & "." & thisdayyy & ".pptm", "destinationDir & "\" & Project_Organigram_" & thisday & "." & thisdayy & "." & thisdayyy & ".pptm"
Function Today_Date()
thisday=Right(Day(Date),2)
thisdayy=Right("0" & Month(Date),2)
thisdayyy=Right("0" & Year(Date),2)
End Function
这会导致文件夹被创建为" T:\ Team \ Archive \ Archive_03.12.2014_1
我的目标是能够将T:\ Team中的文件移动到上面动态创建的文件夹中。
在MoveFile部分之前,一切都很有效。目的地是抛出"类型不匹配的部分"在我定义strDirectory
的行我正在学习这种类型的编程,所以如果我能提供任何进一步的细节,请告诉我!
提前谢谢!
答案 0 :(得分:0)
您的引号会出现几个语法错误,这些错误会相互抵消。将您的行更改为:
filesys.MoveFile "T:\Team\Project_Organigram_" & thisday & "." & thisdayy & "." & thisdayyy & ".pptm", "destinationDir" & "_" & replace(date,"/",".") & "_" & intNum & "\" & "Project_Organigram_" & thisday & "." & thisdayy & "." & thisdayyy & ".pptm"