Command to rename sFTP file with date/time stamp

Advertisement

ak
Guest

Command to rename sFTP file with date/time stamp

Tried Command: mv ! $(echo "!" | sed "s/\..*$//").$(date '+%Y-%m-%d_%H-%M').$(echo ! | awk -F"." '{ print $NF }')

Get error:
Error listing directory 's/\..*$//' .
No such file or directory.
Error code: 2
Error message from server (en): invalid path
Request code: 11

Please advise what 's/\..*$//' should be? Can above command be used on sFTP server?

Reply with quote

Advertisement

Guest

Re: Command to rename sFTP file with date/time stamp

martin wrote:

ak wrote:

Can above command be used on sFTP server?
No.
This example may help you:
https://winscp.net/eng/docs/script_download_timestamped_filename

Thanks for reply. Not quite what I need. Would like to know best way/how to rename an sFTP file with a date/time stamp on the sFTP server using WinSCP to automatically do this.

Example:
File on sFTP server is 'ABC.dat'
I want to rename file on the server to be 'ABC_YYYY_MM_DD.dat'.

Can you advise?

Thank you.

Reply with quote

martin
Site Admin
martin avatar

Re: Command to rename sFTP file with date/time stamp

I know it not exactly, what you need. But it shows how to do this kind of task.

Reply with quote

Advertisement

You can post new topics in this forum