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 
4

1 回答 1

1

Copy在 ASP File 对象上尝试方法,如下所示:

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
于 2012-10-15T13:34:48.473 回答