1PRENAME(1)            User Contributed Perl Documentation           PRENAME(1)
2
3
4

NAME

6       prename - renames multiple files using perl expressions
7

SYNOPSIS

9       prename [-bcfilnv] [-B prefix] [-S suffix] [-V method] [-Y prefix] [-z
10       suffix] [--backup] [--copy] [--basename-prefix=prefix] [--dry-run]
11       [--force] [--help] [--no-stdin] [--interactive] [--just-print]
12       [--link-only] [--prefix=prefix] [--suffix=suffix] [--verbose]
13       [--version-control=method] [--version] perlexpr [files]...
14

DESCRIPTION

16       prename renames the filenames supplied according to the rule specified
17       as the first argument.  The argument is a Perl expression which is
18       expected to modify the $_ string for at least some of the filenames
19       specified.  If a given filename is not modified by the expression, it
20       will not be renamed.  If no filenames are given on the command line,
21       filenames will be read via standard input (unless --no-stdin is
22       supplied on the command line).
23
24       If a destination file is unwritable, the standard input is a tty, and
25       the -f or --force option is not given, prename prompts the user for
26       whether to overwrite the file.  If the response does not begin with `y'
27       or `Y', the file is skipped.
28

OPTIONS

30       -b, --backup
31           Make backup files.  That is, when about to overwrite a file, rename
32           the original instead of removing it.  See the -V or
33           --version-control option fo details about how backup file names are
34           determined.
35
36       -B prefix, --prefix=prefix
37           Use the simple method to determine backup file names (see the -V
38           method or --version-control=method option), and prepend prefix to a
39           file name when generating its backup file name.
40
41       -c, --copy
42           Copy files to the new names instead of renaming them. This will
43           keep the original files.
44
45       -f, --force
46           Remove existing destination files and never prompt the user.
47
48       -h, --help
49           Print a summary of options and exit.
50
51       --no-stdin
52           Disable reading of filenames from STDIN. Us it when your shell has
53           nullglob enabled to make sure prename doesn't wait for input.
54
55       -i, --interactive
56           Prompt whether to overwrite each destination file that already
57           exists.  If the response does not begin with `y' or `Y', the file
58           is skipped.
59
60       -l, --link-only
61           Link files to the new names instead of renaming them. This will
62           keep the original files.
63
64       -n, --just-print, --dry-run
65           Do everything but the actual renaming, instead just print the name
66           of each file that would be renamed. When used together with
67           --verbose, also print names of backups (which may or may not be
68           correct depending on previous renaming).
69
70       -v, --verbose
71           Print the name of each file before renaming it.
72
73       -V method, --version-control=method
74           Use method to determine backup file names.  The method can also be
75           given by the RENAME_VERSION_CONTROL (or if that's not set, the
76           VERSION_CONTROL) environment variable, which is overridden by this
77           option.  This option does not affect whether backup files are made;
78           it affects only the name of any backup files that are made.
79
80           The value of method is like the GNU Emacs `version-control'
81           variable; prename also recognize synonyms that are more
82           descriptive.  The valid values are (unique abbreviations are
83           accepted):
84
85           existing or nil
86               Make numbered backups of files that already have them,
87               otherwise simple backups. This is the default.
88
89           numbered or t
90               Make numbered backups.  The numbered backup file name for F is
91               F.~N~ where N is the version number.
92
93           simple or never
94               Make simple backups.  The -B or --prefix, -Y or
95               --basename-prefix, and -z or --suffix options specify the
96               simple backup file name.  If none of these options are given,
97               then a simple backup suffix is used, either the value of
98               SIMPLE_BACKUP_SUFFIX environment variable if set, or ~
99               otherwise.
100
101       --version
102           Print version information on standard output then exit
103           successfully.
104
105       -Y prefix, --basename-prefix=prefix
106           Use the simple method to determine backup file names (see the -V
107           method or --version-control=method option), and prefix prefix to
108           the basename of a file name when generating its backup file name.
109           For example, with -Y .del/ the simple backup file name for a/b/foo
110           is a/b/.del/foo.
111
112       -z suffix, -S suffix, --suffix=suffix
113           Use the simple method to determine backup file names (see the -V
114           method or --version-control=method option), and append suffix to a
115           file name when generating its backup file name.
116
117       --shell-completion=shell, --shellcompletion=shell
118           Generate shell code for parameter completion for either bash or
119           zsh.
120

EXAMPLES

122       To rename all files matching *.bak to strip the extension, you might
123       say
124
125           prename 's/\e.bak$//' *.bak
126
127       To translate uppercase names to lower, you'd use
128
129           prename 'y/A-Z/a-z/' *
130
131       More examples:
132
133           prename 's/\.flip$/.flop/' *     # rename *.flip to *.flop
134           prename s/flip/flop/ *           # rename *flip* to *flop*
135           prename 's/^s\.(.*)/$1.X/' *     # switch sccs filenames around
136           prename 's/$/.orig/' */*.[ch]    # add .orig to source files in */
137           prename 'y/A-Z/a-z/' *           # lowercase all filenames in .
138           prename 'y/A-Z/a-z/ if -B' *     # same, but just binaries!
139       or even
140           prename chop *~                  # restore all ~ backup files
141

ENVIRONMENT

143       Two environment variables are used, SIMPLE_BACKUP_SUFFIX and
144       VERSION_CONTROL.  See "OPTIONS".
145

SEE ALSO

147       mv(1) and perl(1)
148

DIAGNOSTICS

150       If you give an invalid Perl expression you'll get a syntax error.
151

AUTHOR

153       Peder Stray <pederst@cpan.org>, original script from Larry Wall.
154

BUGS

156       Report any issues at <https://github.com/pstray/rename/issues>.
157
158
159
160perl v5.38.0                      2023-07-21                        PRENAME(1)
Impressum