Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Move Files to Archive

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,64038
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Move Files to Archive
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Move Files to Archive - 9/4/2008 4:09:36 AM   
  snufse

 

Posts: 29
Score: 0
Joined: 9/5/2007
Status: offline
I am doing an FTP and when completed I need to move files to an "archive" folder. The file may already exists in the archive folder and if so I need to replace it. Below is the code I have. When the file already exists in the archive folder It gives me an error "File already exists". I was hoping below code would take care of this. Can anyone help? Thank you.


For Each objFile In fileColl
    If objRegExp.Test(objFile.Name) Then
    strDest = folderName & "archive\" & newFile
           If filesys.fileExists(strDest) Then filesys.DeleteFile strDest
             filesys.MoveFile objFile, strDest
                    If Err.Number <> 0 Then
               objEmail.Subject = "Travelers - ftp error in procedure: Travelers_Inbound_Archive_Encrypted_FTP_Files.vbs"
               objEmail.Textbody = "File: " & objfile & " in Folder: " & foldername & " Process: Archive outbound FTP file(s) failed: " & Err.Number & ") - " & Err.Description
                 objEmail.Send
                 Err.Clear
            End If
        End If
Next
 
 
Post #: 1
 
 RE: Move Files to Archive - 9/6/2008 9:10:47 PM   
  ninjamaster

 

Posts: 107
Score: 0
Joined: 1/23/2007
Status: offline
Why not check for the existance of the file prior to the move and if detected delete it?

(in reply to snufse)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Move Files to Archive Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts