Comment from the forum adminI'm attempting to use the ADDEXCLUSION command and it does not appear to work. Would like to avoid downloading files that are already in the target local directory. Here is how I am using it in my script. Any assistance you could provide is greatly appreciated. Thank you. -Bruce
The ADDEXCLUSION command is often missunderstood. If you stumble upon this thread I suggest you
to visit first the ADDEXCLUSION examples at:
https://www.scriptftp.com/d/ftp-transfer-commands/addexclusion
ADDEXCLUSION(DOWNLOAD,"*.*","C:\landingzone")
Script output: :
OPENHOST("123.123.30.12","userhere","passwordhere")
Connecting to 123.123.30.12
Connected.
LOCALCHDIR("C:\landingzone")
Changing current local directory to C:\landingzone
ADDEXCLUSION(DOWNLOAD,"*.*","C:\landingzone")
Adding "*.*" at "C:\landingzone" to the download exclusion list.
GETLIST(REMOTE_FILES)
Getting file listing of current remote directory
Found 4 files.
GETFILE("08-24-2011-APNJ-DailyReminderReport.xls")
Downloading................. 08-24-2011-APNJ-DailyReminderReport.xls
FTP Script
- #
- #
- #-Go out to SSL secure remXchg site and get client uploaded files
- #-which filenames begin with today's date every 30 minutes.
- #
- #
- #-set log file
- #-connect to FTP server
- #-set current local directory
- #-set filter for files that have already been downloaded
- #-set current remote directory
- #-set variable for todays date to match against
- #-get remote folder/directory list
- #-set the current remote directory
- #-get only files with filename starting with today's date
- #-set the current remote directory back to /uploads/
- #-clear exclusion list
- #-get any/all files that may have been uploaded to the '/upload/' directory
- #-file transfer complete - close connection
- #-close the ScriptFTP window
- #EXIT
I think that the best way to do so is just use the SYNC command. It can be used to download only new or modified files. For example:
If you use ADDEXCLUSION this way:
you are excluding from download any remote file (*.*) that is in the directory C:\landingzone. Obviously this will make ADDEXCLUSION useless as no remote file has the path C:\landingzone (remote paths usually start with '/' instead)
FTP Script
- # Download new and modified files from the remote
- # folder /uploads to C:\landingzone
FTP Script
liked Script FTP? Try our other product Email Parser
I ended up NOT using the ADDEXCLUSION command. I constructed multiple different loops for comparing the newly uploaded customer files to what was brought down locally. This runs every 30 minutes so I wanted to avoid downloading the same files over and over.
Attached is the final script so you can see and you are welcome to post it as I changed the names of the paths, passwords, etc.
Thanks again!
Attached is the final script so you can see and you are welcome to post it as I changed the names of the paths, passwords, etc.
Thanks again!
FTP Script
- #
- #
- #-Go out to SSL secure site and get client uploaded files
- #-which filenames begin with today's date every 30 minutes. If file
- #-already exists in the local LandingZone directory then skip it.
- #
- #
- #-set log file
- #-connect to FTP server
- #-set current local directory and build list of files in the LandingZone
- #-set current remote directory
- #-set all variables for todays date and file(s) to match against when looping files
- $ignorefile="FALSE"
- $uploadedfiles="files:"
- #-get remote folder/directory list
- #-set the current remote directory
- $clientdir=$item
- #-get list of files in remote directory
- $remotefilename=$item
- #-get only files with filename starting with today's date
- #-loop through all files already in the LandingZone directory
- $localfilename=$item
- #-same file already exists, set the ignorefile flag to true
- $ignorefile="TRUE"
- #-skip it
- #-get the file into the local LandingZone directory
- #-build string variable for email message
- $uploadedfiles=$uploadedfiles.$todaysdate."-".$clientdir."-----"
- #-set ignorefile flag back to the default of false
- $ignorefile="FALSE"
- #-set the current remote directory back to /uploads/
- $clientdir="UPLOAD"
- #-now get files that may have been uploaded to the /upload/ parent directory and add to email list
- $remoteparentfilename=$item
- #-loop through all files already in the LandingZone directory
- $localfilename=$item
- #-same file already exists, set the ignorefile flag to true
- $ignorefile="TRUE"
- #-skip it
- #-get the file into the local LandingZone directory
- $uploadedfiles=$uploadedfiles.$todaysdate."-".$clientdir."-----"
- #-send email notification if at least 1 file was downloaded
- $blat_path="C:\windows\system32\blat.exe"
- $smtp_svr="smtp.mysvr.com"
- $smtp_usr="support@mycompany.com"
- $smtp_pwd="mypwd"
- $email_from="support@remxchg.com"
- $email_to="me@mycompany.com"
- $email_subject="files_uploaded_from_clients"
- $email_body=$uploadedfiles
- $emailiT=$blat_path." -server ".$smtp_svr." -u ".$smtp_usr." -pw ".$smtp_pwd." -f ".$email_from." -to ".$email_to." -subject ".$email_subject." -body ".$email_body
- #-file transfer complete - close connection
- #-close the ScriptFTP window