Home > database >  linux_rename files in directory by prepending with timestamp using find command
linux_rename files in directory by prepending with timestamp using find command

Time:10-13

I am trying to rename files in current directory by prepending timestamp value using find command like below

 find . -type f -exec mv {} $(date  %Y-%m-%d)_{} \;

But getting 'Can't move, no such file or directory error', but appending works well with below command, not sure what is the difference between two.

 find . -type f -exec mv {} {}.$(date  %Y-%m-%d) \;

CodePudding user response:

Try this

find . -type f -exec mv {} $(date  %Y-%m-%d)$(basename {}) \;
  • Related