2012-10-15 38 views
1

我有一個很長的文件名,其中包含許多無關字符,需要減少並在其中附加昨天的日期。我想到了這一點 - 感謝谷歌。我需要將文件從當前位置移動到另一個網絡位置 - 這是我重複失敗的部分。我相信這是由於文件沒有實際創建,而只是一個變量被定義。我已經看了這麼久,但我沒有看到這個錯誤。任何人都可以指出我忽略了什麼?未創建或複製文件

我相信你需要的所有部件都貼在下面 -

Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objMessage = CreateObject("CDO.Message") 
Set objShell = WScript.CreateObject("WScript.Shell") 
Set objshell = CreateObject("Wscript.shell") 

'On Error Resume Next 

'Get current date 
'----------------------- 
strMonth = Month(Date) 
If len(strMonth) = 1 Then 
     strMonth = "0" & strMonth 
End if 

strDay = Day(Date) 
If Len(strDay) = 1 Then 
     strDay = "0" & strDay 
End if 

strYear = Year(Date) 

'strHour = Hour(Time) 

'strMinute = Minute(Time) 

'strSecond = Second(Time) 

strDate = strYear & strMonth & strDay 

strPastDay = strDate -1 
'----------------------- 

'Specify variables for Emails 

'----------------------------- 
strScriptServer = "TECHOPSPC01" 
strScriptPath = "\\TECHOPSPC01\C$\Scripts\CSI\Capture\..." 
strScriptName = "DFX_Loans_Past_Due file Move to FSCHAUNI01" 
'strToEmail = "" 
'strCCEmail = 
strProcessID = "[LPDR-01]" 
strCustomerImpact = "LOW" 
strCorporateImpact = "LOW??" 
'------------------------------- 

'Specify variables for File Paths 
'strFromPath1 = "\\techopspc01\C$\CSIeSafeDFX\receive" 
'strToPath1 = "\\fschauni01\group_share\special assets retail\special assets\past due report\" 
strFromPath1 = "C:\CSIeSafeDFX\receive" 
strToPath1 = "c:\treasury\Public funds\" 
'Specify variable for File 
strFile1 = "DFX_Loans Past Due by PDR*.xls" 
strNewFile1 = "DFX_LoansPastDueByPDR" 
'#######################' 


If Right(strFromPath1, 1) <> "\" Then 
     strFromPath1 = strFromPath1 & "\" 
End If 


     objShell.Run "cmd /c move ""C:\CSIeSafeDFX\receive\DFX_Loans Past Due by PDR*.xls"" C:\CSIeSafeDFX\receive\DFX_LoansPastDueByPDR" 
     Wscript.Sleep 4000 
     strNewFile2 = "DFX_Loans Past Due By PDR" & strPastDay & ".xls" 
     strNewFile2 = strNewFile1 & strPastDay & ".xls" 
     objFSO.CopyFile strFromPath1 & strNewFile2, strToPath1, True 
'  objFSO.DeleteFile strFromPath1 & NewFile1 
     blnEmailNotification = true 

回答

1

嘗試Copy方法ASP文件對象上有這樣的事情:

dim fs,f 
set fs=Server.CreateObject("Scripting.FileSystemObject") 
set f=fs.GetFile("c:\test.txt") 
f.Copy("c:\new_test.txt",false) 
set f=nothing 
set fs=nothing 
+0

意志工作的一個VBScript? – user1747184

+0

它爲我工作了幾次.. – greener