Roland0 wrote:
> >
Code:
--------------------
> >
> #!/usr/bin/perl
>
> use File::Path qw(make_path);
> use File::Basename;
> use File::Spec;
> use File::Copy;
>
> my $target = "/mnt/usbstick";
> my $cf = 0;
> my $sim = 1;
>
> while( <> ) {
> /^#.*/ && next;
> chomp;
> ($volume,$directories,$file) = File::Spec->splitpath( $_ );
> my @dirs = File::Spec->splitdir( $directories );
> my $adir = $dirs[$#dirs-1];
> my $dpath = File::Spec->catdir( ($target, $adir) );
> $dpath =~ s/[:'"?!]//g;
> if ( $dpath =~ /.* $/) {
> chop( $dpath);
> }
> my $dfile = File::Spec->catfile($dpath , $file);
> if( $sim == 1) {
> print "dpath: $dpath dfile: $dfile";
> if (! -f "$dfile" ) {
> print " [copy]\n";
> } else {
> print " [no copy]\n";
> }
> continue;
> }
>
> ( -d "$dpath" ) || make_path( "$dpath");
> ( -f "$dpath/cover.jpg" ) || copy("$directories/cover.jpg","$dpath");
> ( -f "$dpath/cover.png" ) || copy("$directories/cover.png","$dpath");
> if( $file =~ /\.flac$/) {
> $file =~ s/\.flac$/.mp3/;
> if( -f File::Spec->catfile($dpath , $file) ) {
> print "[skip] $_ (mp3 exists at destination)\n";
> next;
> }
> }
> if (! -f "$dfile" ) {
> print "[copy] $_ to $dpath\n";
> copy( "$_", "$dpath");
> $cf++;
> }
> }
> print "copied $cf files\n";
>
--------------------
> >
> copy code into a file (e.g. m3ucopy.pl)
> make file executable
> adjust path in $target
> test ($sim = 1 means simulate, change to $sim = 0 to actually copy)
> run ./m3ucopy.pl < /path/to/playlist.m3u
> script preserves one directory level (e.g. "Artist -
> Album"/track.mp3)
> doesn't copy flac if mp3 of same base name exists
That looks very interesting !
2 questions
1) Does the script copy the .m3u file(s) itself to the usbstick ?
2) If it does, how do you deal with a .flac file referenced within an
m3u which has been left out in preference for an .mp3 ?
PI3 PCP/LMS STORAGE QNAP TS419P (NFS)
*Living Room* - Joggler & SB3 -> Onkyo TS606 -> Celestion F20s
*Office* - Pi3+Sreen -> Sony TAFE320 -> Celestion F10s / Pi2+DAC & SB3
-> Onkyo CRN755 -> Wharfedale Modus Cubes
*Dining Room* -> SB Boom
*Kitchen* -> UE Radio (upgraded to SB Radio)
*Bedroom (Bedside)* - Pi2+DAC ->ToppingTP21 ->AKG Headphones
*Bedroom (TV)* - SB Touch ->Sherwood AVR ->Mordaunt Short M10s
Everything controlled by iPeng
------------------------------------------------------------------------
d6jg's Profile: http://forums.slimdevices.com/member.php?userid=44051
View this thread: http://forums.slimdevices.com/showthread.php?t=108762
_______________________________________________
Squeezecenter mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/squeezecenter