Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Batch rename perl script
Perl Groff Shell
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
LICENSE
PKGBUILD
README.md
mkmanual.sh
rename.pl
rename.pl.1
rename.pl.1.ronn

README.md

rename.pl(1) -- rename files using Perl expressions

SYNOPSIS

rename.pl options file1 [file2 ...]

DESCRIPTION

This script allows renaming files using Perl expressions, such as regular expression replaces (s/old(\d{2})/new\1/), character translation (y/abc/ABC/), or any valid expression that alters $_.

It also allows conversion between encodings, and Unicode normalization of file names, which is useful for files copied from OS X.

OPTIONS

  • -v: Be verbose.

  • -vv: Be very verbose.

  • --apply: Really apply modifications. Without this, no transformation will be done.

  • -e PERLCODE: Executes PERLCODE for each file. To actually change file names, the new name must be put into $_.

  • --from-charset=CS: Source charset. (e.g. "iso-8859-1")

  • --to-charset=CS: Destination charset. (e.g. "utf-8")

  • --unicode-normalize=NF: Unicode normalization form. (e.g. "KD")

  • --basename: Modifies only the last element of the path.

  • --debug: Prints generated function.

EXAMPLES

None of these examples will actually rename anything. To apply changes, add --apply to the end of the command.

Change prefix "old" to "new" for old*.png:

    rename.pl -ve 's,^old,^new,g' old*.png

Convert lowercase to uppercase in file names, but preserve case of extension:

    rename.pl -ve 'y/a-z/A-Z/; s,\.PNG$,.png,g' *.png

Rename *.png to 000.png, 001.png, 002.png, ...

    rename.pl -ve '$_ = sprintf("%03d.png", $i++)' *.png

Convert lowercase to uppercase in file names, but preserve case of directory names:

    rename.pl --basename -ve 'y/a-z/A-Z/;' */*.png

Convert charset from ISO-8859-1 to UTF-8:

    rename.pl -v --from-charset=iso-8859-1 --to-charset=utf-8 *.png

Compose diacriticals in file names (useful for files copied from OS X):

    rename.pl -v --unicode-normalize=KC *.png

Decompose diacriticals in file names (useful for files copied to OS X):

    rename.pl -v --unicode-normalize=KD *.png

COPYRIGHT

rename.pl is Copyright (C) 2014 André von Kugland kugland@gmail.com.

Something went wrong with that request. Please try again.