The follwing code copies a file from one location to another. What I need to do is once copied over to rename it as another program is looking to pick up this file but must only be able to when it is fully copied over and not partially so. Therefore once its been copied over I need to perform this operation. Any ideas?
'--------------------------------------------------------------------------------------------
' Declare constants
'--------------------------------------------------------------------------------------------
Const DATA_PATH = "D:\Gblon1so4\Datatrue\"
Const MOVE_PATH = "D:\Gblon1so6\Shared\WebReportData\NewData.csv"
'--------------------------------------------------------------------------------------------
' Declare the objects
'--------------------------------------------------------------------------------------------
Set FSO = CreateObject("Scripting.FileSystemObject"
Set objFolder = FSO.GetFolder(DATA_PATH)
Set colFiles = objFolder.Files
'--------------------------------------------------------------------------------------------
' Search for the correct file
'--------------------------------------------------------------------------------------------
For Each FileObj In colFiles
Dim File_String
File_String = Right(FileObj, 5)
If File_String = "X.csv" Then
Copy_File(FileObj.Name)
End If
Next
'--------------------------------------------------------------------------------------------
' Move the file and rename it. Delete the initial file
'--------------------------------------------------------------------------------------------
Sub Copy_File(filename)
FSO.CopyFile DATA_PATH & filename, MOVE_PATH
FSO.DeleteFile DATA_PATH & filename
End Sub
'--------------------------------------------------------------------------------------------
' Declare constants
'--------------------------------------------------------------------------------------------
Const DATA_PATH = "D:\Gblon1so4\Datatrue\"
Const MOVE_PATH = "D:\Gblon1so6\Shared\WebReportData\NewData.csv"
'--------------------------------------------------------------------------------------------
' Declare the objects
'--------------------------------------------------------------------------------------------
Set FSO = CreateObject("Scripting.FileSystemObject"
Set objFolder = FSO.GetFolder(DATA_PATH)
Set colFiles = objFolder.Files
'--------------------------------------------------------------------------------------------
' Search for the correct file
'--------------------------------------------------------------------------------------------
For Each FileObj In colFiles
Dim File_String
File_String = Right(FileObj, 5)
If File_String = "X.csv" Then
Copy_File(FileObj.Name)
End If
Next
'--------------------------------------------------------------------------------------------
' Move the file and rename it. Delete the initial file
'--------------------------------------------------------------------------------------------
Sub Copy_File(filename)
FSO.CopyFile DATA_PATH & filename, MOVE_PATH
FSO.DeleteFile DATA_PATH & filename
End Sub