I am using the following command to transfer from a SFTP location to a local folder. This transfers all the files from the SFTP location to the local folder.
How do I transfer files that are only for e.g. older than yesterday?
cmd /c c:/putty/pscp -q -batch -pw password -i C:/putty/key_pk.ppk -r root@xx.xxx.xxx.xxx:/home/user/Folder1/* C:/LocalFolder1/SFTP/
Thanks.
The pscp
cannot do that.
All you can do, is to the list all the files using the -ls
switch, parse the output to find the old files and generate a download script for the identified files.
Or use an SCP/SFTP client capable of selecting files by their timestamp.
For example with WinSCP SFTP/SCP client, you can use the following batch file (.bat
) to download the files older than one day:
winscp.com /log=c:\path\to\winscp.log /command ^
"open sftp://root:password@xx.xxx.xxx.xxx/ -privatekey=""C:\putty\key_pk.ppk"" -hostkey=""ssh-rsa 2048 xxxxxxxxxxx...=""" ^
"get -filemask=<1D /home/user/Folder1/* C:\LocalFolder1\SFTP\" ^
"exit"
References:
(I'm the author of WinSCP)