Quintessential script for renaming images in a directory on your Windows desktop
#!usr/bin/perl # VARIABLES $filePath = 'C:/Documents and Settings/user/Desktop/ripped_images/'; $ext = '.gif'; @fileCurrentNames = &getDirectoryList($filePath); foreach $fileName (@fileCurrentNames) { #print &getFileName($fileName)."n"; $fileName = &getFileName($fileName); $old = $filePath.$fileName; $new = $filePath.'r_fr_'.$fileName; #print $old."n".$new."nn"; rename ($old, $new); } #getFileName sub getFileName($file) { my $file = $_[0]; @sections = split(///,$file); return $sections[$sections - 1]; #Make c:imageName.jpg into just imageName.jpg. } #getPrefix sub getPrefix($file) { my $file = $_[0]; @sections = split(///,$file); @prefix = split(/./,$sections[$sections - 1]); return $prefix[$prefix - 2]; #Make c:imageName.jpg into just imageName } #getSuffix sub getSuffix($file) { my $file = $_[0]; @sections = split(///,$file); @suffix = split(/./,$sections[$sections - 1]); return $suffix[$suffix - 1]; #Make c:imageName.jpg into just .jpg } #getDirectoryList sub getDirectoryList($path) { my $path = $_[0]; $path =~ s/ /\ /g; #Correct Path Errors by escaping spaces. #C:/Documents and Settings/* will become C:/Documents and Settings/* #Append the characters '*' to enable the glob if (!($path =~ /*/)) { $path = $path.'/*'; } return glob($path); }simple_image_renamer.pl

