#!/usr/bin/perl # (untested) script to create .desktop entries for mp3 files on a remote mount # this assumes that the directory in $docdir exists already my $mp3dir = '/mnt/sathome/mp3s'; # where your mp3 files are mounted (absolute path) my $docdir = '/mnt/card/Documents/audio/mpeg'; # where you want the .desktop files to go (absolute path) die "Couldn't find $mp3dir" unless (-e $mp3dir); die "Couldn't find $docdir" unless (-e $docdir); foreach (`find $mp3dir -name *.mp3`) { chomp; my $filename = $_; my $filenamenoext = $_; $filenamenoext =~ s/^.*\///; $filenamenoext =~ s/\.mp3//; my $target = "$docdir/$filenamenoext.desktop"; print "Found $filename.\n"; if (-e $target) { print "$target already exists, skipping.\n"; next; } print "Creating $target .. "; if (open (TARGET, ">$target")) { print TARGET qq~[Desktop Entry] Comment = An MP3 file File = $filename Icon = SoundPlayer Name = $filenamenoext Type = audio/mpeg ~; close (TARGET); print "OK\n"; } else { print "oops!\nCouldn't create $target, $!"; } }