Skip to content
Advertisement

linux_rename files in directory by prepending with timestamp using find command

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) ;

Advertisement

Answer

Try this

find . -type f -exec mv {} $(date +%Y-%m-%d)$(basename {}) ;
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement