Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript to Upload Daily Files

Status
Not open for further replies.

ekinike

IS-IT--Management
Oct 20, 2001
123
US
How can I alter the following VBscript so that it only uploads files created on the same day the script is executed, and not any old files?

' VBS Script Generated by CuteFTP (TM) macro recorder.
' Create TEConnection object
Set MySite = CreateObject("CuteFTPPro.TEConnection")
' Initialize remote server host name, protocol, port, etc.
MySite.Host = "ftpserver"
MySite.Protocol = "SFTP"
MySite.Port = 22
MySite.Retries = 30
MySite.Delay = 30
MySite.MaxConnections = 2
MySite.TransferType = "AUTO"
MySite.DataChannel = "DEFAULT"
MySite.AutoRename = "OFF"
' WARNING!!! SENSITIVE DATA: user name and password.
MySite.Login = "userid"
MySite.Password = "********"
MySite.SocksInfo = ""
MySite.ProxyInfo = ""
' Connect to remote server
MySite.Connect
MySite.Upload "d:\test\*.*", "/ftpserverdir"
MySite.Disconnect

The local directory "d:\test\" has a thousands of files and I want to prevent any files that have already been uploaded from being transfered every time the script runs again. Deleting any files that once they have been uploaded is not an option. Also, once the files are uploaded to the FTP server, they are immediately moved from the directory on the FTP server to a shared directory on the internal LAN.

Any suggestions?
 
ekinike,
look at the datlastmodified of the file.
something like:
Code:
Dim obj_FSO
Dim char_Dir
Dim obj_Folder
Dim obj_FileColl
Dim obj_File
Dim obj_ArcFile1
Dim int_DaysOld
Dim char_date
int_DaysOld = 10 'age in days
char_Dir = "C:\rweb\wmisc" 'target dir
Set obj_Folder = obj_FSO.GetFolder(char_Dir)
Set obj_FileColl = obj_Folder.Files
'DateLastModified is what is shown via explorer in windose
'can also use DateCreated and DateLastAccessed based upon needs

For each obj_File in obj_FileColl
	If DateDiff("d", obj_File.DateLastModified,Now ()) > int_DaysOld Then
		do yourwork
	End If
Next

'clear objects
Set obj_FSO = Nothing
Set obj_Folder = Nothing
Set obj_FileColl = Nothing
Set obj_File = Nothing
Set obj_ArcFile1 = Nothing
untested and you will have to change the vars to your needs but this should get you going.
regards,
longhair
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top