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

Author Message


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
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"

[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25748
Location: Prague, Czechia
Your probably wanted -filemask=">2016-12-08 00:00:00"


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.
GET_maskfirst_FTPScriptRun.log (3.36 KB) [Download]

Description: (none)

GET_FTPScriptRun.log (3.36 KB) [Download]

Description: (none)

SYNC_FTPScriptRun.log (3.36 KB) [Download]

Description: (none)



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

You can post new topics in this forum

Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License