NAME

File::Rename - Perl extension for renaming multiple files

SYNOPSIS

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);

DESCRIPTION

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.

SEE ALSO

mv(1), perl(1), rename(1)

HISTORY

Revision history for Perl extension File::Rename.

Larry Wall

Revision: 4.1 Date: 92/08/07 17:20:30

Robin Barker
# Revision 1.1  1997/02/27  15:48:51  rmb1
# Initial revision

# Revision 1.2  1997/02/27  16:15:40  rmb1

# Revision 1.3  1997/02/27  16:39:07  rmb1
# added -v

# Revision 1.4  1997/02/27  17:19:26  rmb1
# corrected usage string

#Revision 1.5  1998/12/18 16:16:31  rmb1
# moved to perl/source
# changed man documentation to POD
0.01 Mon Dec 13 17:54:05 2004

original version; created by h2xs 1.23 with options -XAn File::Rename

0.02 Robin Barker 2006-01-13

Added t/pod*.t, and extended POD to pass tests

0.03 Robin Barker 2007-09-26

Added --force and --nono options (over_write, no_action)

0.04 Robin Barker 2007-09-27

Replaced depencies on perl versions by explicit requirements on modules in Build.PL/Makefile.PL

0.05 Robin Barker 2007-10-03

Removed perl 5.6.0 dependencies and successfully tested on perl 5.005_05 (with patched Temp::File).

0.06 Robin Barker 2011-09-23

Added example/rename.pl, dealt with other Kwalitee metrics.

Updated META files

0.09 (beta for 0.10) Robin Barker 2006-06-26 - not released

Added options -e, -f, -n and -V (version).

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

0.10 Robin Barker 2013-04-29

Merged "0.09 (beta for 0.10)" from 2006-06-26

Added option -V (version).

0.20 Robin Barker 2013-04-30

Added option -E (statement): alternative to -e

0.30 Robin Barker 2018-06-02

(tidied configure_requires)

removed typo from rename POD

options do not need to before code / files

allow null separated file names reading from STDIN

0.31 Robin Barker 2018-06-05

Removed use of s///r in tests

Rewrote tests - more robust - use of testlib.pl

0.32 Robin Barker 2018-06-08 - as 0.32-fix

Fixed syntax of rmtree() for perl5.16

0.33 Robin Barker 2018-06-13

Added return code for File::Rename::rename

More tests: in preparation for v1.00

Add $File::Rename::Options::VERSION

0.35 Robin Barker 2018-06-14

Add $File::Rename::Options::VERSION

0.99_01 Robin Barker 2018-06-12

File::Rename::Options in separate file

0.99_02 Robin Barker 2018-06-26

Remove spurious opendir in t/File-Rename-script.t

1.00 Robin Barker 2018-07-03

File::Rename::Options module

1.09_01 Robin Barker 2018-09-16

Option for renaming file component only: filename-only/-d

1.09_02 Robin Barker 2018-09-16

Fix test failure for perl 5.14

1.09_03 Robin Barker 2018-09-17

Change options to closer align to original feature request

1.09_04 Robin Barker 2018-09-19

Added CONTRIBUTING

Fixed file 'log' which was supposed to be deleted

1.10 Robin Barker 2018-09-25

Added option --filename [-d] to rename filename component only

Added option --fullpath [--path] to rename any part of path

1.11 Robin Barker 2020-06-16

Added more examples in the script POD, suggested by 'xavier'

Added a test script to test that examples in POD are valid

1.12 Robin Barker 2020-06-17

Added new test script to MANIFEST

1.13 Robin Barker 2020-06-17

Fix 'examples' test script to do file globbing

1.19_01 Robin Barker 2021-03-17

Fix Makefile and tests to find script on darwin

1.19_02 Robin Barker 2021-03-18

More robust OSType handling

1.19_03 Robin Barker 2021-03-19

Fix META.* for Makefile.PL

1.19_04 Robin Barker 2021-03-20

Fix distribution file format

1.20 Robin Barker 2021-03-22

On darwin, when built with ExtUtils::MakeMaker, builds the correct script and passes tests; see

http://matrix.cpantesters.org/?dist=File-Rename%201.19_04;os=darwin;reports=1

1.29_01 Robin Narker 2021-07-31

Add -u to do utf8::upgrade and unicode_strings

1.29_02 Robin Narker 2021-08-01

Add File::Rename::Unicode to hide use feature

1.29_03 Robin Narker 2021-08-01

Fix tests which should skip

1.29_04 Robin Narker 2021-08-02

Tests which should skip_all: BEGIN { plan skip_all =>

1.29_05 Robin Narker 2021-08-03

Add encoding to --unicode

Reworked create() in testlib.pl:

  • removed unnessary die

  • simplified File-Rename-unicode.t

1.29_06 Robin Barker 2021-08-04 - not released

Documented approach to unicode strings in README

1.30 Robin Barker 2021-08-16

Unicode support: --unicode and File::Rename::Unicode

1.30_01 Robin Barker 2021-08-16

Fix tests for perl < 5.8.9 (on cygwin)

1.30_02 Neil Bowers 2021-09-05

Add LICENCE=>perl to Makefile.PL

1.30_03 Robin Barker 2022-04-23

Add explicit 'cygwin' in test lib and script

1.31 Robin Barker 2022-05-07

Add explicit LICENCE field

Fix tests for perl 5.8.* and cygwin

1.90_1 Robin Barker 2022-12-19

require_order in script

New script unsafe-rename with no_require_order

Rewrite examples to mark start of non-options

1.90_2 Robin Barker 2022-12-20

Add :config to use File:Rename, to mimic GetOpt::Long

Fix cygwin tests - cygwin is not Windows

See http://www.cpantesters.org/cpan/report/41cc76dd-84fd-1014-94ee-444106f7812f

1.90_3 Robin Barker 2022-12-22

Increase required version of ExtUtils::MakeMaker

Add test for unsafe script

1.90_4 Robin Barker 2022-12-23

Remove Build.PL - so testers build and test unsafe-rename

More globbing in rename-examples.t

Test for warnings in rename-examples.t

1.90_5 Robin Barker 2022-12-24

Add back Build.PL for 1.99 - to be removed for 2.00

README and POD for 1.99

1.99 Robin Barker 2022-12-24

rename script requires options before code/files

New script unsafe-rename with no_require_order: to recover the old behavior of the rename script

1.991 Robin Barker 2022-12-27

Add required ExtUtils::MakeMaker version to BUILD_REQUIRES and CONFIGURE_REQUIRES

Separate out TEST_REQUIRES from PREREQ_PM

Fix typos in 1.99 POD and Changes file

1.992 Robin Barker 2022-12-27

Reinstate shebang line

https://rt.cpan.org/Ticket/Display.html?id=145711

1.99_9 Robin Barker 2022-12-28

Remove Build.PL from distribution

Set MIN_PERL_VERSION in Makefile.PL

2.00 Robin Barker 2022-12-31

rename script requires options before code/files

New script unsafe-rename with no_require_order

Removed Build.PL from distribution

2.00_1 Robin Barker 2023-01-14

min perl version 5.6.1

use warnings

use Getopt::Long 2.24

2.00_3 Robin Barker 2023-01-15

Restore indirect print in t/testlib.pl

Change regex for $INC values

2.00_2 deleted

2.00_4 Robin Barker 2023-01-16

Min perl version 5.8.0

Move rename source file to source/ - to avoid rename being found when @INC includes '.'

Revert regex for $INC values

Initialize our $print for v5.10

2.01 Robin Barker 2023-01-17

min perl version 5.8.0

use warnings

use Getopt::Long 2.24

source/rename source of rename script

2.01_91 Robin Barker 2023-12-27

replace use 5.032; on old perl

add evn var FILE_RENAME_TEST to test old perl

added example of using options in code

2.01_99 Robin Barker 2023-12-28

Move Changes to HISTORY in Pod

AUTHOR

Robin Barker <RMBarker@cpan.org>

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.

COPYRIGHT AND LICENSE

Copyright (C) 2004, 2005, 2006, 2011, 2018, 2021, 2022, 2023 by Robin Barker

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.