#!/usr/bin/perl -w use strict; my $dir = "c:/Xwords/"; my $n=length "c:/Xwords/"; # There must be a better way of doing this => Please?? my $from = '.puz'; my $to = 'A.puz'; my $newdir = "c:/Xwords/PrintedXwords/"; while (<$dir*$from>) { # checking for .puz files my ($old,$new,$full); # declaring variables $old = $full = $_; # setting the full filename and path $new = $old = substr $_,$n; # removing the path details of filename $new =~ s/$from$/$to/; # changing the old file name print " \n \n"; print " full name of original file is $full \n"; print " name of original file is $old \n"; print " full name of new file is {$newdir.$new} \n"; # does not concatenate - leaves the '.' visible print " \n \n"; rename $full, {$newdir.$new}; } print "Files renamed !"; exit