1
1
There are many files in a directory on a server which are generated by a process. How to get latest file (order by date descending) that is generated using psftp?
1
1
There are many files in a directory on a server which are generated by a process. How to get latest file (order by date descending) that is generated using psftp?
3
The psftp
does not have such feature.
You would have to:
psftp
once with ls
command and output it to a filepsftp
run.Instead, you can use WinSCP scripting and its get -latest
command instead.
Example batch file (.bat):
winscp.com /log=download.log /ini=nul /command ^
"open sftp://username:password@example.com -hostkey=""...""" ^
"get -latest /remote/path/* C:\local\path\" ^
"exit"
There's a guide for Converting PuTTY PSFTP script to WinSCP script.
Or even easier, you can have WinSCP GUI generate the script/batch file for you. All you need to do manually is to add the -latest
switch.
(I'm the author of WinSCP)