#!/usr/bin/perl use strict; use warnings; my $initial_path = `pwd`; chomp($initial_path); &correct_files($initial_path); sub correct_files { my $path = shift; my @files = `ls $path`; foreach ( @files ) { chomp; if ( -f "$path/$_" ) { open FILE, "<$path/$_"; my @lines = ; foreach my $line ( @lines ) { chomp $line; $line =~ s/(([a-zA-Z0-9\_\-\/\.]+)\.(jpg|jpeg|gif|html|htm|php|css))/\L$1/g; } close FILE; open NEWFILE, ">$path/$_"; foreach my $line ( @lines ) { print NEWFILE $line; print NEWFILE "\n"; } close NEWFILE; } elsif ( -d "$path/$_" ) { correct_files("$path/$_"); } if ( m/[A-Z]+/ ) { my $new_file = lc($_); system("mv", "$path/$_", "$path/$new_file"); } } }