
# (assuming two digits at the beginning and a 3 character extension # rename "12-lovely-spam.txt" to "lovely-spam-12.txt" \1, \2 etc) are supported too: # rename "spam.txt" to "spam-spam-spam.py" # only replace 'foo' at the beginning of the filename Simplest usage: # replace all occurences of 'foo' with 'bar' Use -w to actually write changes when you are satisfied with the dry run result, -s to suppress displaying non-matching files -h or -help will show usage notes. Statement: code to act on files name, as -e but terminated by ‘ ’.My take on a friendly recursive regex file name renamer which by default only emulates the replacement and shows what the resulting file names would be. If no -e, the first argument is used as code. May be repeated to build up code (like “perl -e”). Over write: allow existing files to be over-written.Įxpression: code to act on files name. No action: print names of files to be renamed, but don’t rename. Verbose: print names of files successfully renamed. To install, run the the following command: You may have to install it on Ubuntu Linux Systems. Please note that the rename command is part of the util-linux package.

In simple words, the first commands describes what to do and the second one tells that the same operation will be executed on all files with the specified extension. The second command argument directs the system to rename all the files with *.jpg extension.

The first command argument is a perl expression that tells the system to rename the file with.

Now let use learn a bit about the command.

We will use rename command to change this file to png. You can see in the screenshot above that we have only one png file named krusader.jpg. Let us see how to use rename command to rename all jpg files to png. Rename *|perlexpr įor example, to rename all files matching “*.jpg” to png, we will use the rename command as rename ‘s/\.jpg$/\.png/’ *.jpg You can also use the command to translate uppercase names to lower, you’d use rename ‘y/A-Z/a-z/’ *
