Batch rename image files sequentially via perl script

Aug 29, '07 07:30:00AM

Contributed by: erfmufn

I wanted to use the QuickTime "Image Sequence" feature to make rapid MPG movie out of a folder of JPGs. The problem was there were 600 pictures taken with my iSight over seven months, so I used a simple perl script to bulk-rename the files (it actually uses cp, so your original files are untouched). After running the script, open QuickTime, choose File » Open Image Sequence, and select 1.jpg, then the frame rate, etc. Here's an example of the finished product. (I used the iSight auto-capture hint I submitted earlier this year.)

Here is the perl (rename.pl):

#!/usr/bin/perl

$iteration=1;

foreach my $file (`ls *.jpg`) {
    chop($file);
    system("cp $file $iteration.jpg;");
    $iteration++;
    }
[robg adds: I haven't tested this one.]

Comments (12)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20070827193937744