File::Rename(3pm)

File::Rename3pm

Perl extension for renaming multiple files

Usage

  use File::Rename qw(rename);          # hide CORE::rename
  rename \@ARGV, sub { s/\.pl\z/.pm/ }, 1;
  use File::Rename;
  File::Rename::rename \@ARGV, '$_ = lc';
  use File::Rename qw(:config no_require_order);

Overview

Use options

Parameters to "use File::Rename" consists of functions to be imported and configuration options.

The only exported function is "rename()". The configuation options are preceded by :config, and are passed to File::Rename::Options.

Functions

"rename( FILES, CODE [, VERBOSE])"

rename FILES using CODE, if FILES is empty read list of files from stdin

"rename_files( CODE, VERBOSE, FILES)"

rename FILES using CODE

"rename_list( CODE, VERBOSE, HANDLE [, FILENAME])"

rename a list of file read from HANDLE, using CODE

Options

FILES

List of files to be renamed, for "rename" must be an ARRAY reference

CODE

Subroutine to change file names, for "rename" can be a string, otherwise it is a code reference

VERBOSE

Flag for printing names of files successfully renamed, optional for "rename"

HANDLE

Filehandle to read file names to be renames

FILENAME (Optional)

Name of file that HANDLE reads from

Hash

Either CODE or VERBOSE can be a HASH of options.

If CODE is a HASH, VERBOSE is ignored and CODE is supplied by the _code key.

Other options are

verbose

As VERBOSE above, provided by -v.

input_null

Input separator \0 when reading file names from stdin.

no_action

Print names of files to be renamed, but do not rename (i.e. take no action), provided by -n.

over_write

Allow files to be over-written by the renaming, provided by -f.

filename_only

Only apply renaming to the filename component of the path, provided by -d.

show_help

Print help, provided by -h.

show_manual

Print manual page, provided by -m.

show_version

Print version number, provided by -V.

unicode_strings

Enable unicode_strings feature, provided by -u.

encoding

Encoding for filenames, provided by -u.

Export

rename

Environment

No environment variables are used.

Acknowledgements

Based on code from Larry Wall.

Options -e, -f, -n suggested by more recent code written by Aristotle Pagaltzis.

Diagnostics

Errors from the code argument are not trapped.

Releases

5 releases since Debian 8 (Jessie); the text changed 4 times.

  1. 8
  2. 9
  3. 10
  4. 11
  5. 12

Author

Robin Barker <[email protected]>

From rename 2.01-1 in Debian 12 (Bookworm). Parsed by carta from the page's man source.