文件未被创建或复制

时间:2012-10-15 13:14:54

标签: file vbscript creation

我有一个很长的文件名,里面有许多无关的字符,需要减少并附加昨天的日期。我认为那部分 - 感谢Google。我需要将文件从其当前位置移动到另一个网络位置 - 这是我反复失败的部分。我认为这是由于文件实际上没有被创建而只是一个被定义的变量。我已经看了这么久,但我没有看到错误。任何人都能指出我在忽视的东西吗?

我相信您需要的所有部件都张贴在下面 -

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 个答案:

答案 0 :(得分:1)

使用以下内容在ASP File对象上尝试Copy方法:

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