2005-03-04 Software

On my Apple, I have to open a terminal, change the directory to my mounted MP3 player, and rm -rf everything, including .Trash. Then I have to unmount and unplug it, and replug it. If I don’t do that, the Trash will be forever stuffed. And I don’t want to empty the global trash. Then I drag all the MP3 I want from my iTunes into a temporary directory and run my *shuffle* script.

#!/usr/bin/perl
opendir(D,".") || die "can't opendir current directory: $!";
@files = grep { /\.mp3$/ && -f $_ } readdir(D);
closedir DIR;
for $f (@files) {
  $n = $f;
  $n =~ s/^[-0-9 ]+//;
  $num = sprintf("%04d", int(rand(10000)));
  rename($f, "$num-$n") || die "can't rename $f: $!";
}

Without it, my MP3 player will just play the files in alphabetical order. Very boring.

When done renumbering the files, I copy them onto the MP3 device. Strangely I cannot rename them on the device itself: I run out of space! (As if renaming involves making a copy of the files...)

​#Software