I’ve been exploring ways to encode videos and create playlist for my Nokia N96 without using Nokia’s PC Suite. I use openSUSE11.1 and hardly boot into my dual boot windows. Nokia implements usb storage and so E:\ gets mounted as a USB volume in linux. You can copy or move music and video files easily once the volume is mounted. I use the following code to create a playlist once the music files are copied. I’m still trying to figure out a way for this playlist to appear in Nokia’s Music player. Currently, I use the file manager, browse to the playlist and play from there.

#!/usr/bin/perl -w

# Utility to create a Nokia playlist
# Usage: nokia-playlist.pl .....
# Not much error checking. Make sure the first file is always the playlist file
# Also, this script needs to be executed from the directory where mp3 files are present.
# playlist name can contain a directory name, but mp3 files should always be in the current directory.
# This script assumes that all files are in a directory called Music in your Nokia's Mass Storage drive (E:\)

use Cwd;

#
# Get the current working directory. Change the directory seperator or '\' and prepend E:\
#
sub getCurrentWorkingDirectory
{
$_ = getcwd;
chomp;
s{;.*$}{};
s{^a:}{^E:};
s{/}{\\}g;

if (m{=[0-9A-F]{2}}) {
s{=([0-9A-F]{2})}{chr(hex($1))}ge;

my $s = eval { decode('utf-8', $_); };
$_ = $s unless ($@);
}
#
# Note: Change the following line if you have a different directory or drive structure.
#
s/.*\\Music[\\]??/E:\\Music/;
print "Directory is $_\n";
$_[0] = $_;
}

print "Number of arguments: $#ARGV \n";

my @files;
my $playlist = $ARGV[0];
my $PLFH;
if ( ! -e $playlist )
{
print"Playlist file $playlist does not exist. Creating new...\n";
open(PLFH, ">$playlist");
print PLFH "#EXTM3U\n";
}
else
{
open(PLFH, ">>$playlist");
}

foreach $argnum (1 .. $#ARGV)
{
if ( -e $ARGV[$argnum] ) { push (@files, $ARGV[$argnum]); }
else { push(@files, <$ARGV[$argnum]>); }

}

$pwd = getCurrentWorkingDirectory();
foreach (@files) {

# $_ = $file;
print PLFH '#EXTINF:0, -';
print "...Adding $pwd\\$_ . \n";
print PLFH "$pwd\\$_";
}

close(PLFH);