Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

btownguy

macrumors 6502a
Original poster
Jun 18, 2009
545
19
I have multiple Gb's of photos I'll be migrating from Windows over to my Mac (iPhoto). I have them categorized in folders named after the events they represent. I've taken the pictures with various cameras over the years, and there is very little rhyme or reason to the file names. Lots of DSC_xxxx.jpg's, and IMG_xxxx.jpg's, etc. Does it make sense to do some kind of mass file rename before I begin working with them on the Mac in iPhoto?
 
Perl script for mass file renames

The following Perl script renames multiple files quite nicely. In terminal create a new file called rename.pl and here is the script:

#!/usr/bin/perl
# rename: renames files according to the expr given on the command line.
# The expr will usually be a 's' or 'y' command, but can be any valid
# perl command if it makes sense. Takes a list of files to work on or
# defaults to '*' in the current directory.
# e.g.
# rename 's/\.flip$/.flop/' # rename *.flip to *.flop
# rename s/flip/flop/ # rename *flip* to *flop*
# rename 's/^s\.(.*)/$1.X/' # switch sccs filenames around
# rename 's/$/.orig/' */*.[ch] # add .orig to your source files in */
# rename 'y/A-Z/a-z/' # lowercase all filenames in .
# rename 'y/A-Z/a-z/ if -B' # same, but just binaries!
# rename chop *~ # restore all ~ backup files

use Getopt::Std;
my ($subst, $name);

if (!&getopts("nfq") || $#ARGV == -1) {
die "Usage: rename [-fnq] <perl expression> [file file...]
-f : Force the new filename even if it exists already
-n : Just print what would happen, but don't do the command
-q : Don't print the files as they are renamed
e.g. : rename 's/\.c/.c.old/' *
rename -q 'y/A-Z/a-z/' *\n";
}

$subst = shift; # Get perl command to work on
@ARGV = <*> if $#ARGV < 0; # Default to complete directory

foreach $name (@ARGV) {
$_ = $name;
eval "$subst;";
die $@ if $@;
next if -e $_ && !$opt_f; # Skip if the file exists if asked to.
next if $_ eq $name;
if ($opt_n) {
print "mv $name $_\n";
next;
}
print "mv $name $_\n" if !$opt_q;
rename($name,$_) or warn "Can't rename $name to $_, $!\n";
}

After you edit the file (use vi or similar) and exit the editor then make rename.pl executable using 'chmod +x rename.pl'. There are examples in the script to see how it works. Try it out and have fun.

Chuck
 
what you can also do is use iphoto's batch change operation to change it the whole library to sequential numbers. It might be less useful than the script suggested, but it helped me out a lil bit when i was bored n fed up with all my files being higglypiggedly. cmd>shft>B should sort you out :)

PTP
 
I agree with the other poster, renaming them makes little sense and isn't worth the effort.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.