#!/usr/bin/perl -w # # Picasa Export 0.1, January 2011 # by Philipp C. Heckel; No license, feel free use it! # # Picasa Export renames the pictures of an exported Picasa album to maintain # the original sort order of the album. # # Original blog post: # http://blog.philippheckel.com/2011/01/12/picasa-for-linux-export-pictures-in-sort-order/ # # REQUIREMENTS # Perl module XML::Simple; in Debian/Ubuntu, install libxml-simple-perl # # USAGE # 1. Export Picasa album using "Export to HTML Page" function; # Select "XML Code" in the template list. Click "Export". # 2. Navigate to the folder in the console and type: # $ ./picasa-export ~/"Picasa HTML Exports/YourAlbum" # 3. The new folder "neworder" includes the renames pictures. # use XML::Simple; if (scalar(@ARGV) != 1) { die("Usage: picasa-export [EXPORTED PICASA ALBUM]\n"); } if ((! -d $ARGV[0]) || (! -e "$ARGV[0]/index.xml")) { die("ERROR: Directory '$ARGV[0]' does not exist or is not an exported Picasa album.\n"); } my $folder = $ARGV[0]; my $xs1 = XML::Simple->new(); my $doc = $xs1->XMLin("$folder/index.xml"); my $padding = 3; my $number = 1; mkdir("$folder/neworder"); foreach my $key (@{$doc->{images}->{image}}) { my $name = trim($key->{itemName}); my $newname = ("0" x ($padding - length($number))) . $number . ext($name); print "Move $folder/images/$name to $folder/neworder/$newname ...\n"; rename("$folder/images/$name","$folder/neworder/$newname"); $number++; } sub trim { my $s = shift; $s =~ s/^\s+|\s+$//g; return $s; } sub ext { my $_ = shift; return (/(\.[^.]+)/) ? $1 : ""; }