Name |
ren-regexp
|
Version |
1.6 |
Updated |
2003/12/28 08:01:25 |
RCS |
ren-regexp,v 1.6 2003/12/28 08:01:25 forman Exp forman |
Rating |
|
Category |
File manipulation |
Description |
ren-regexp applies one or more regular expressions to a list of file names. This provides a method of applying common modifications to many files that would otherwise require repetitive, atomic file operations.
|
Download |
ren-regexp
|
|
forman:1> ls
MVCD-00050.JPG
MVCD-00051.JPG
forman:2> ren-regexp "s/JPG/jpg/" "s/MVCD/Vacation/" *
MVCD-00050.JPG
1 MVCD-00050.jpg
2 Vacation-00050.jpg
MVCD-00051.JPG
1 MVCD-00051.jpg
2 Vacation-00051.jpg
forman:3> ls
Vacation-00050.jpg
Vacation-00051.jpg
|
|
REN-REGEXP(1) User Contributed Perl Documentation REN-REGEXP(1)
NAME
ren-regexp - Rename files by the application of regular
expressions
SYNOPSIS
ren-regexp [ -dhtv ] [ -cfgiqu ] [regexp ...] [file ...]
DESCRIPTION
ren-regexp applies one or more regular expressions to a
list of file names. This provides a method of applying
common modifications to many files that would otherwise
require repetitive, atomic file operations.
OPTIONS
-c --color
-u --underline
The "--color" and "--underline" options can be used
together or separately to highlight changes in the file
name as the regular expression are applied.
-d --debug
Print additional information useful for debugging.
-f --force
If the new file exists, this will force an overwrite.
-g --global
Apply all regular expressions globally to a filename.
This is equivalent to appending a "g" to the end of each
regular expression as in "s/regexp/string/g".
-h --help
Prints this information.
-i --insensitive
Apply all regular epxression without sensitivity to case.
This is equivalent to appending an "i" to the end of each
regular expression as in "s/regexp/string/i".
-q --quiet
ren-regexp is rather verbose for a unix program. Consider
this a feature to prevent data loss. To keep things
quiet, use this option.
-t --test
Test the application of the regular expressions without
renaming the files. This is highly recommended to prevent
the loss of data.
EXAMPLE
The following example shows standard usage. The regular
expression, "s/.mp3/ of 3.mp3/", is applied to the three
files resulting in files matching the pattern "PI-01 of
3.mp3".
ren-regexp "s/.mp3/ of 3.mp3/" PI-01.mp3 PI-02.mp3
PI-03.mp3
The following examples all have the same result. Note
that the initial "s/" are both optional with the final "/"
option if there is no modifier.
ren-regexp "s/A/B/i" *
ren-regexp -i "s/A/B/" *
ren-regexp "A/B/i" *
ren-regexp -i "A/B" *
The following example shows three regular expressions
applied in turn on a filename. The file progresses from
the original of "ABCD.txt" to "abCD.txt", "ABcD.txt", and
finally "AcDB.txt". The single quote is necessary to pre
vent the shell from expanding the regular expression vari
ables, "$1" and "$2".
ren-regexp "AB/ab" "abC/ABc" '(B)(cD)/$2$1' ABCD.txt
BUGS
The color ouput doesn't like regular expressions variables
(i.e., "$1").
SEE ALSO
mv
AUTHOR AND COPYRIGHT
Michael Forman
http://www.Michael-Forman.com
Copyright (C) 2000, 2001, 2002 Michael Forman. All rights
reserved. This program is free software; you can redis
tribute it and/or modify it under the same terms as Perl
itself. Please see the Perl Artistic License.
VERSION
Current Revision: $Revision: 1.6 $ Last Modification:
$Date: 2003/12/28 08:01:25 $
perl v5.8.1 2004-03-16 REN-REGEXP(1)