Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: d39abc6a8e
Fetching contributors…

Cannot retrieve contributors at this time

executable file 85 lines (54 sloc) 1.506 kB
#!/usr/bin/env perl
use warnings;
use strict;
use Getopt::Long;
use Pod::Usage;
use File::Copy;
my $man = 0;
my $help = 0;
my $directory = '.';
my $verbose;
GetOptions('help|?' => \$help,
man => \$man,
'directory=s' => \$directory,
verbose => \$verbose )
or pod2usage(2);
pod2usage(1) if $help;
pod2usage( -exitstatus => 0,
-verbose => 2 ) if $man;
my @files = glob( "$directory/*" );
FILE: foreach my $filename ( @files ) {
( my $newfilename = $filename ) =~ s/\s+/_/g;
print "renaming $filename to $newfilename\n" if $verbose;
if ( copy( $filename, $newfilename ) ) {
unlink( $filename );
} else {
warn "unable to rename $filename to $newfilename: $!";
next FILE;
=head1 NAME - renames files to remove spaces.
=head1 SYNOPSIS --verbose --directory /tmp/foo
--directory the directory to deal with. defaults to "."
-help brief help message
-man full documentation
--verbose be verbose
=head1 OPTIONS
=over 8
=item B<--directory>
The directory that you want to fix.
defaults to ".".
=item B<--verbose>
prints out the list of files that are being changed
=item B<-help>
Print a brief help message and exits.
=item B<-man>
Prints the manual page and exits.
renames all of the files in a directory to names that don't contain spaces.
Jump to Line
Something went wrong with that request. Please try again.