find: rename files with a prefix


Rename and prefix all files with 0 in the current and nested directories:

find . -type f -execdir mv {} 0{} \;

For example, given the file directory structure:

tree
.
├── 1.txt
├── 2.txt
└── 3.txt

0 directories, 3 files

After running the script:

find . -type f -execdir mv {} 0{} \;

The files will be renamed to:

tree
.
├── 01.txt
├── 02.txt
└── 03.txt

0 directories, 3 files

See more find examples.



Please support this site and join our Discord!