It’s a mess, it’s a hack, but it does work. Make sure iTunes and Safari are opened before running.
#! /usr/bin/perl
# Erica Sadun, 9 April 2006
%countries = ("143460", "Australia", "143445", "Austria", "143446", "Belgium", "143455", "Canada", "143458", "Denmark", "143447", "Finland", "143442", "France", "143443", "Germany", "143448", "Greece", "143449", "Ireland", "143450", "Italy", "143462", "Japan", "143451", "Luxembourg", "143452", "Netherlands", "143457", "Norway", "143453", "Portugal", "143454", "Spain", "143456", "Sweden", "143459", "Switzerland", "143444", "UKt", "143441", "USt");
# Iterate through each country.
foreach $item (reverse sort keys(%countries))
{
print "Switch to ".%countries->{$item}."?t[n] ";
if (prompt() =~ "y.*")
{
loadCountry($item);
print "Press return to continue."; prompt();
}
}
# Prompt [y/n] (default is "n")
sub prompt
{
$| = 1; $_ = <STDIN>; chomp;
my $yn = $_ ? $_ : "n"; $yn =~ tr /A-Z/a-z/;
return $yn;
}
# Use jingle API to load the country
sub loadCountry
{
my $countrycode = shift;
$doit = "osascript -e 'tell application \"Safari\" to activate'; osascript -e 'tell application \"Safari\" to set URL of document 1 to \"http://phobos.apple.com/WebObjects/MZStore.woa/wa/com.apple.jingle.app.store.DirectAction/switchToStoreFront?storeFrontId=$item\"'";
# Load Country
print "Loading ".%countries->{$countrycode}."n";
`$doit`;
# Bring Terminal to front--or at least frontish
$doit = "osascript -e 'tell application \"Terminal\" to activate'";
`$doit`;
}


Is this legal?
Sure it's legal. There's a pop-up at the bottom of the main iTunes page that lets you do exactly the same thing. This is just a way to do it from the command line rather than using your mouse.
Nevermind, I see now that it doesn't allow you to make a purchase. :(
I'm a newbie, just exactly how do you use this script to make it work? I need directions :) :)
The updated version is now available.