Synchronize Script to add newly added files to a seperate local directory

Advertisement

kcopeland
Guest

Synchronize Script to add newly added files to a seperate local directory

I am trying to write a script that will synchronize only new and updates files (for the last day/week) from a sftp/ftp site to a local directory. I am able to crate the local directory and copy all files off the ftp site. However, when I add -filemask for a given # of days or specific data the script pulls nothing.

I've tried several times with Syncronize and get and cannot seem to pull only files created before/after certain dates or new files added.

version: 5.9.3(Build 7136)


rem Generate Temp Script
@echo off
setlocal
set folder=%date:~10,4%%date:~4,2%%date:~7,2%
set script=FTPScript.txt

echo option confirm off >> "%script%"
echo open FTP_TEST >> "%script%"
echo synchronize -filemask="<2016-12-08 00:00:00" local "C:\Users\User\Desktop\FTP_TEST\%folder%\"  "/sftp/FTP_TEST/" >> "%script%"

:echo get -filemask="<2016-12-08 00:00:00" /sftp/FTP_TEST/*  "C:\Users\User\Desktop\FTP_TEST\%folder%"\ >> "%script%"

echo close >> "%script%"
echo exit >> "%script%"


rem Create Date folder in Local Environment
set folder=%date:~10,4%%date:~4,2%%date:~7,2%
cd "C:\Users\User\Desktop\FTP_TEST\
mkdir %folder% 
cd %folder% 

rem Execute Script
"C:\Program Files (x86)\Winscp\winscp.exe" /script="C:\Users\User\Desktop\DateApp\FTPScript.txt" /log="C:\Users\User\Desktop\DateApp\FTPScriptRun.log"


rem Delete temporary script
del "C:\Users\User\Desktop\DateApp\FTPScript.txt"

exit

Reply with quote

Advertisement

kcopeland
Guest

Re: Synchronize Script to add newly added files to a seperate local directory

I have tried several ways
-there are a couple of files that were added in Nov with Oct created date and a file that I added on the 12/8.

All the the following: no files are copied (tried other iterations but fact I cant any files to copy when I use -filemask -- is the syntax incorrect?)


echo synchronize -filemask=">2016-12-07 00:00:00" local "C:\Users\E964422\Desktop\FTP_TEST\%folder%\" "/sftp/FTP_TEST/" >> "%script%"


echo get /sftp/FTP_TEST/* -filemask=">2016-12-07 00:00:00" "C:\Users\E964422\Desktop\FTP_TEST\%folder%"\* >> "%script%"


echo get -filemask=">2016-12-07 00:00:00" /sftp/FTP_TEST/* "C:\Users\E964422\Desktop\FTP_TEST\%folder%"\* >> "%script%"


If I remove the -filemask to files copy/sync to the local drive.

Reply with quote

kcopeland
Guest

Re: Synchronize Script to add newly added files to a seperate local directory

Gosh the syntax does not work in version 4.04 and when I changed to the new version I forgot to name the saved session the same so that was the reason noting was copying.


echo get /sftp/FTP_TEST/ -filemask="*>7D" "C:\Users\username\Desktop\FTP_TEST\%folder%"\* >> "%script%"


works like a charm when using a 5.9.3

Reply with quote

Advertisement

You can post new topics in this forum