0

I want to move the files with current date using plink

 @ECHO OFF
plink administrator@10.7.20.214 -pw TestPa (mv /home/shared/administrator/scripts/sam  /home/shared/administrator/scripts/sam_`date +"%Y%m%d_%H%M"`)`

But at the output file is updated as sam_mHM. I want it to be sam_20191218_1422

user1107731
  • 357
  • 1
  • 2
  • 10

1 Answers1

0

You have to double the % symbols to get them through a local batch file interpreter to the server.

plink username@example.com -pw password (mv /path/sam /path/sam_`date +"%%Y%%m%%d_%%H%%M"`)

Alternatively, you can format the timestamp locally in the batch file instead of using the remote date command:
How do I get current date/time on the Windows command line in a suitable format for usage in a file/folder name?

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