#!C:/perl ########################################################### #Copyright (C) 2006 Jon Camfield # #This program is free software; you can redistribute it and/or #modify it under the terms of the GNU General Public License #as published by the Free Software Foundation; version 2 #of the License # #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details. # #You should have received a copy of the GNU General Public License #along with this program; if not, write to the Free Software #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ########################################################### use strict; use Carp::Heavy; use Env; use Env qw(PATH HOME TERM); my $listname; my $outputdir; print "PlayListCopy version 0.1, Copyright (C) 2006 Jon Camfield\nPlayListCopy is GPLv.2 software and comes with with ABSOLUTELY NO WARRANTY\n"; print "\nUsage: Drag an m3u playlist onto the executable and it will copy all the files from the playlist onto your Windows desktop in a folder named the same as your playlist\n"; my $basedir = join('',$ENV{'USERPROFILE'}, '\\Desktop\\'); my $listdrop = $ARGV[0]; if ($listdrop =~ m/\\?(.*)\.m3u/) { $listname = $1; } if (!$ARGV[0]) { print "\nNo playlist provided!\n\n"; print "parsing failed. \nPress Return to exit parser\n"; #This holds the window open: getc(); exit; } elsif (!$listname){ print "\n\nNot a valid .m3u file!\n"; print "\n\nUsage: Drag an .m3u playlist onto me! I will copy all the songs in it to the desktop in a folder named as the playlist.\n\n"; print "parsing failed. \nPress Return to exit parser\n"; #This holds the window open: getc(); exit; } else { print "\nParsing the playlist $ARGV[0]\n"; unless ($listname =~ m/:/) { $outputdir = join('','"',$basedir,$listname,'\\"'); } else { $outputdir = join('','"',$listname,'\\"'); } print "\nCopying files to $outputdir\n"; my $direxists = system "mkdir $outputdir"; if ($direxists/256 == 1) { print "Directory Exists! Append and overwrite existing files? (Y/N) "; my $value = getc(); if(!($value eq "Y") && !($value eq "y")) { die "\nquitting parser\n"; } } open(PLAYLIST, $ARGV[0]); my @songs = ; close (PLAYLIST); listparse: foreach my $s (@songs) { if ($s =~ m/^#.*/) { #print "\ncomment: $s\n"; } else { $s =~ s/\n//g; $s = join('',' "',$s,'" '); my $copy = join('','copy',$s,$outputdir,); print "\n$copy\n"; system $copy; } } print "--------parsing completed successfully \nPress Return to exit parser\n"; #This holds the window open: getc(); }