Introduction
- A command on ubuntu to deal with files.
Description
Usage:
rename [ -h|-m|-V ] [ -v ] [ -n ] [ -f ] [ -e|-E perlexpr]*|perlexpr
[ files ]
Options:
-v, -verbose
Verbose: print names of files successfully renamed.
-n, -nono
No action: print names of files to be renamed, but don't rename.
-f, -force
Over write: allow existing files to be over-written.
-h, -help
Help: print SYNOPSIS and OPTIONS.
-m, -man
Manual: print manual page.
-V, -version
Version: show version number.
-e Expression: code to act on files name.
May be repeated to build up code (like "perl -e"). If no -e, the
first argument is used as code.
-E Statement: code to act on files name, as -e but terminated by
';'.
Example
-> ls 1.txt 2.txt 3.txt
rename 's/\.txt/\.m/' * # replace the postfix with another
rename 's/^/prefix-/' * # add a prefix to the filename
rename 's/$/\.postfix/' * # add a postfix to the filename
rename 's/\.txt//' * # delete the postfix
rename 's/[]//g' * # delete the space on the filename
rename 's/[()]//g' * # delete the parentheses on the filename
rename 'y/A-Z/a-z/' * # translate the capital letter to the lowercase letter