command line - WinSCP time based file download -
i write winscp script download file placed onto remote server every morning between 4-4:30am. there way time-stamping?
i want pseudocode:
get file.txt timestap<1 hour 4
first, assume file not have fixed name (contrary question fixed name file.txt
). if not, please explain, why need timestamp-based solution.
anyway, can use file mask time constraint:
get "*.txt>2014-07-19 4:00"
to dynamically inject today's date, use %timestamp%
syntax:
get "*.txt>%timestamp#yyyy-mm-ss% 4:00"
simply, above means, files created later 4:00 today (the %timestamp#yyyy-mm-ss%
resolves today's date in format yyyy-mm-ss
, needed time constraint).
when passing get
on winscp command-line in batch file (using /command
switch, opposite using /script
switch specify separate script file), have double %
avoid batch-file trying interpret %timestamp%
:
winscp.com /command ... "get ""*.txt>%%timestamp#yyyy-mm-ss%% 4:00"""
another solution static script rely on relative time: e.g. know script runs @ 6am. let winscp download files updated/created in last 2 hours (6am-4am):
get *.txt>2h
see winscp article on downloading recent file.
Comments
Post a Comment