#!/bin/perl use warnings; use strict; use File::Find; use File::Copy; my $path = $ARGV[0]; my $from = $ARGV[1]; my $to = $ARGV[2]; die "You must supply a full directory path" unless (-e $path && -d $path); finddepth(\&renamedir, "$path"); # find -> finddepth sub renamedir { return if -f $_; return if /^\./; my $new_name = $_; $new_name =~ s/$from/$to/g; move($_, $new_name) or die $!; }