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

Author Message
kcopeland

Guest


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)


Code:
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
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
Location: Prague, Czechia
Your probably wanted -filemask=">2016-12-08 00:00:00"

https://winscp.net/eng/docs/file_mask#size_time
https://winscp.net/eng/docs/faq_script_modified_files
kcopeland

Guest


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)

kcopeland

Guest


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
Advertisements

You can post new topics in this forum






Search

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!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License