2014-12-03 168 views
0

我正在處理VBS中的一個備份腳本,該腳本創建一個文件夾,然後將PowerPoint文件複製到最近創建的文件夾中。使用VB腳本將文件移動到動態創建的文件夾

一切正常,除了在底部 這裏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:\隊伍\存檔\ Archive_03.12.2014_1

我的目標是能夠將文件移動在T:\團隊上面動態創建的文件夾

一切都很好,直到MoveFile部分。目標是在我定義strDirectory的行上拋出「類型不匹配」的部分我只是在學習這種類型的編程,所以請讓我知道,如果我可以提供任何進一步的細節!

預先感謝您!

回答

0

您的語句錯誤與您的引號相互取消。你行改成這樣:。!

filesys.MoveFile "T:\Team\Project_Organigram_" & thisday & "." & thisdayy & "." & thisdayyy & ".pptm", "destinationDir" & "_" & replace(date,"/",".") & "_" & intNum & "\" & "Project_Organigram_" & thisday & "." & thisdayy & "." & thisdayyy & ".pptm" 
+0

讓您「在'」 destinationDir」和‘_’'會導致'destinationDir_'這無疑不打算 – 2014-12-03 14:20:28

+0

感謝您的快速反應它現在說的路徑不能找到,我會繼續玩你給我的東西,看看我是否忽略了一些東西 – SeattleITguy 2014-12-03 14:24:21

+0

@ Ekkehard.Horner - 我只是指出是什麼原因導致了錯誤,我不會做任何假設OP的意圖超出了修正錯誤 – 2014-12-03 14:24:29

相關問題