Hi All.
I am trying to set up the downloads from FTP server using a scheduled batch job. Currently, I am testing it manually and it works. It downloads to a folder, tccfiles.
I use the below code to Move files from folder, tcc to another folder. TCC.
Before moving to the new folder, I need to check if the file already exists and if it does, should skip that file(s) and move the rest.
I am trying to set up the downloads from FTP server using a scheduled batch job. Currently, I am testing it manually and it works. It downloads to a folder, tccfiles.
I use the below code to Move files from folder, tcc to another folder. TCC.
Before moving to the new folder, I need to check if the file already exists and if it does, should skip that file(s) and move the rest.
Code:
Dim file As Object
' Create FileSystemObject
Set FSO = CreateObject("Scripting.FileSystemObject")
' Define source and destination folders
sourceFolder = "C:\software\winscp\tccfiles\"
' Change to your source folder path
destinationFolder = "C:\inputspipe\TCC\"
' Change to your destination folder path ' Ensure the source folder exists
If Not FSO.FolderExists(sourceFolder) Then
MsgBox "Source folder does not exist!", vbExclamation
Exit Function
End If
' Ensure the destination folder exists or create it
If Not FSO.FolderExists(destinationFolder) Then
FSO.CreateFolder (destinationFolder)
End If
' Loop through each file in the source folder
For Each file In FSO.GetFolder(sourceFolder).Files
' Move file to the destination folder
file.Move destinationFolder & FSO.GetFileName(file.Path)
[B]'need to check if the file already exists in the destination folder ------[/B]
Next file
' Clean up Set FSO = Nothing
MsgBox "Files moved successfully!", vbInformation
End Function
[/CODE
I need help with the code.
TIA