-1

We want to connect to a remote machine using SCP in windows. We want to copy only the recently modified file and hence we would like to list the contents of the directory in sorted order so as to choose the required file. Need help with scp commands if any available in Windows which can help us perform the above action

Searched in the internet and could find only commands with respect to copy

CVS
  • 73
  • 8

1 Answers1

1

WinSCP (which you have referenced yourself) can download the latest file from an SCP server.

The following batch file will do:

winscp.com /command ^
    "open scp://username:password@example.com/ -hostkey=""...""" ^
    "cd /remote/path" ^
    "lcd c:\local\path" ^
    "get -latest *" ^
    "exit"

Use WinSCP GUI to generate batch-file template like the one above for you, including the correct value for the -hostkey switch. You just need to add the -latest switch.

See also WinSCP article Downloading the most recent file.

Though note that SCP is an obsolete protocol. You better use SFTP. Majority of servers, that do support SCP, support SFTP too. Just replace scp:// with sftp://.

(I'm the author of WinSCP)

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992