wikiti
12/28/2017 - 11:52 AM

Rename file extensions in a directory tree

Rename all file extensions recursively within a given directory.

# Use find command, executing rename
find DIR -name "*.EXT1" -type f -exec rename 's/\.EXT1$/.EXT2/' '{}' \;

# For example, to rename all file extensions from 'text' to 'txt':
find /home/daniel -name "*.text" -type f -exec rename 's/\.text$/.txt/' '{}' \;

# To change all extensions in a directory:
find DIR -type f -exec rename 's/\.[0-9A-Za-z]+$/.EXT2/' '{}' \;