cliver wrote:
> Thanks Roland0, sound like exactly what I'm after. I'd appreciate if you
> would post it please.
>
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
SW: 'Web UI for LMS'
(http://forums.slimdevices.com/showthread.php?98186-Announce-Alternative-Web-Interface-(beta))
| 'Playlist Editor / Generator'
(http://forums.slimdevices.com/showthread.php?108199-Announce-LMS-Playlist-Editor)
| 'Music Classification'
(http://forums.slimdevices.com/showthread.php?108278-Announce-Essentia-Integration-music-classification-(moods-genres-))
| 'Similar Music'
(http://forums.slimdevices.com/showthread.php?108495-Announce-LMSmusly-play-similar-music)
| 'LMSlib2go' (https://www.nexus0.net/pub/sw/lmslib2go/)
HowTos: 'build a self-contained LMS'
(http://forums.slimdevices.com/showthread.php?99648-Howto-build-a-self-contained-LMS)
| 'Ogg Opus'
(http://forums.slimdevices.com/showthread.php?107011-Howto-play-Ogg-Opus-files)
| 'Bluetooth/ALSA'
(http://forums.slimdevices.com/showthread.php?107230-Howto-Bluetooth-streaming-to-from-LMS-(ALSA-only-no-PulseAudio))
------------------------------------------------------------------------
Roland0's Profile: http://forums.slimdevices.com/member.php?userid=56808
View this thread: http://forums.slimdevices.com/showthread.php?t=108762
_______________________________________________
Squeezecenter mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/squeezecenter