Linux - Adding a prefix or suffix to all files recursively

In this example we are going to add a suffix -suffix to the filename.

You can start a dry-run to see what would happen:

find . -type f -exec echo {} {}-suffix ';'
./test.2 ./test.2-suffix
[...]
When you are happy with the result, run the following command:
find . -maxdepth 1 -type f -exec mv {} {}-suffix ';'
we replaced echo with mv

Bonus: rename only files in the current directory use the -maxdepth 1 option like find . -maxdepth 1 -type f [...].



Most recent Articles:
  • Notice Board 003: Progress is Progress
  • How to: Cisco ISE backup to SFTP repository with public key authentication
  • Dummy IP & MAC Addresses for Documentation & Sanitization
  • Deploying ISSO Commenting System for Static Content using Docker
  • Generate a Vanity v3 Hidden Service Onion Address with mkp224o