pren − rename files using Perl regular expressions (perl rename)
pren −e perl_regex [−h(elp)] [−n(o_rename)] [−q(uiet)] [−v(erbose)] file...
pren renames files using Perl regular expressions
−e perl_regex
Specify the Perl regular expression to be used for file renames.
−h |
Print help and quit. | ||
−n |
Do not actually rename any files. Instead, echo the rename command that would be used. | ||
−q |
Be quiet. Suppress the usual messages that list the file renames that actually occur. | ||
−v |
Be verbose. Generate messages for file renames that are skipped because the name does not change. |
Turn all instances of "apple" into "orange":
pren −e
’s/apple/orange/’ apple01.txt apple02.txt
apple03.txt
Yields: orange01.txt orange02.txt orange03.txt
Improve the naming of digital camera images:
pren −e
’s/^dsc/wedding/’ dsc*.jpg
Yields: wedding*.jpg
Rearrange date format:
pren −e
’s/(\d\d)(\d\d)(\d\d)/20${3}-${1}-${2}/’
xmas_123104.txt
Yields: xmas-2004-12-31.txt
Poor man’s lowercase utility:
pren −e
’y/[A-Z]/[a-z]/’ DSC*.JPG
Yields: dsc*.jpg
Replace all underscores with spaces:
pren −e ’s/_/
/g’ song_name_*.mp3
Yields: "song name *.mp3"
Rename all files in a directory hierarchy:
find . −depth
−print0 | xargs −0 pren −e
’s/apple/orange/’
Note: The "−depth" switch is necessary to
rename files before
renaming the directories that contain them.
Symbolic links are not handled well by pren. For example, suppose you have a file called "FOObar" and a symbolic link called "BARfoo" pointing to it. If you rename both of them using pren, the symlink will become broken, as it will still point to "FOObar".
lowercase(1), uppercase(1), perl(1), perlop(1), perlre(1), prename(1), rename(1), mmv(1)
Copyright (C) 2005-2020 by Brian Lindholm. This program is free software; you can use it, redistribute it, and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.