Skip to main content

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 [...].