[How To] UNIX one-liner to rename all files with a particular string in file name

One can use 'rename' command to rename the files. rename gives the user the flexibility of conditional renaming.
We can use rename command to rename only the file names that contain a particular string to new filename.


$ rename 's/old_filename/new_filename/' *


s stands for substitute.
oldfilename is the text to find in the name of the file
new_filename is the text to be replaced
* denotes all files in the current directory structure

Below is a snapshot of the terminal which explains rename command.

rename command [click on the image to enlarge]

No comments :

Post a Comment