Quick Linux Tip #23:
Try: rename 's/IMG_(\d+)\.jpg/photo_$1.jpg/' *.jpg
Info: The Perl rename command uses regex to rename files in bulk. -n is a dry-run option that shows what would change without actually renaming files.
Examples:
- $ rename -n 's/\.jpeg$/\.jpg/' *.jpeg # Dry-run preview
- $ rename 'y/A-Z/a-z/' *.TXT # Lowercase extension/file
- $ rename 's/(.+)/prefix_$1/' *.log # Prepend prefix
Note: Ubuntu/Debian use Perl rename. Always test with -n first. RHEL/Fedora use a different rename implementation; install prename or perl-rename as appropriate.
Follow @LinuxTeck for more #LinuxTips
Leave a Reply