SYNOPSIS
Usage:
perlmv -h
perlmv [options] <scriptlet> <file...>
perlmv [options] -e <code> <file...>
perlmv -e <code> -W <name>
perlmv -L
perlmv -S <name>
perlmv -D <name>
Usage examples
$ ls
A.txt B1 c2.txt D3.pl D4.pl
Rename files with prewritten scriptlet (ls) and show (-v) each file as it is being renamed.
$ perlmv -v lc *.txt
`A.txt` -> `a.txt`
Specify script in command line (-e) but do not actually rename files (-d, dry-run mode):
$ perlmv -de 's/\d+//g' *
`B1` -> `B`
`c2.txt` -> `c.txt`
`D3.pl` -> `D.pl`
`D4.pl` -> `D.pl.1`
Really rename the files this time:
$ perlmv -e 's/\d+//g' *
Save Perl code as scriptlet (in ~/.perlmv/scriptlets/):
$ perlmv -e 's/\d+//g' -W remove-digits
List all scriptlets (add -v to also show their contents):
$ perlmv -L
lc
uc
remove-digits
Show source code of scriptlet:
$ perlmv -S remove-digits
s/\d+//g
Remove scriptlet:
$ perlmv -D remove-digits
DESCRIPTION
Perlmv lets you rename files using Perl code. All the Perl code needs to do is modify the filename in $_
and perlmv will do the rest (actual renaming, recursive renaming, handling filename conflicts, dry-run mode, etc.).
Perl code will first be run (eval-ed) once at the beginning for testing, with -TEST
as the filename in $_
(and $TESTING
will be defined). Perl code is not run under strict/warnings. Perl code is run under App::perlmv::code
namespace.
Perl code can be specified directly from the command line (using -e), or by name in ~/.perlmv/scriptlets/NAME
, or in /usr/share/perlmv/scriptlets/
, or in %scriptlets
in App::perlmv::scriptlets, or in %scriptlets
in App::perlmv::scriptlets::std.
OPTIONS
-c Only test compile code, do not run it on the arguments
-e <CODE> Specify code to rename file (\$_), e.g. 's/\.old\$/\.bak/'
-d Dry-run (implies -v)
-f Only process files, do not process directories
-h Show this help
-o Overwrite (by default, ".1", ".2", and so on will be appended to
avoid overwriting existing files)
-r Recursive
-V Print version and exit
-v Verbose
-L list all scriptlets
-S <NAME> Show source code for scriptlet
-W <NAME> Write code specified in -e as scriptlet
-D <NAME> Delete scriptlet
HISTORY
I wrote perlrename
0.01 back in 2003 and have been using it daily. In 2010 I uploaded version 0.24 as perlmv
to CPAN, with ability to store & read scriptlets.