Freelancer's Playground! New knowledges every now and then

14Oct/0810

Copy 3MU Playlist to Directory

One day, I want to copy music from my amarok playlist's to my cellphone. This playlist has so many files that spread across directories. As a php ninja, I create a php script to do the hard work>:).

Here's the script if you want to try:

<?php
$playlist_file = $argv[1];
$output_dir = $argv[2];
$lines = array_map("trim", file($playlist_file));

if(!is_dir($output_dir)) mkdir($output_dir);

foreach($lines as $line)
{
	if(substr($line, 0, 1) == "#") continue;
	if(file_exists($line))
	{
		$filename = basename($line);
		echo "$filename\r\n";
		copy($line, $output_dir."/".$filename);
	}
}
?>

Use it this way php 3mu_copier.php /path/to/3mu/files/playlist.3mu /path/as/target/copy/.


  • http://tiyangsae.wordpress.com/ gum

    Hi, your blog is very interesting.
    Visit my blog for tons of adult movies.

    *nyamar jadi sepam*

  • http://tiyangsae.wordpress.com gum

    Hi, your blog is very interesting.
    Visit my blog for tons of adult movies.

    *nyamar jadi sepam*

  • http://tiyangsae.wordpress.com/ gum

    lho, aku tadi nyamar jadi komen sepam kok gak masuk ya? moderated kah? ato emang ketangkep beneran? :D

  • http://tiyangsae.wordpress.com gum

    lho, aku tadi nyamar jadi komen sepam kok gak masuk ya? moderated kah? ato emang ketangkep beneran? :D

  • http://ferdianto.com/ ferdhie

    pake shell ajah
    grep -v ‘^#’ test.m3u | sed ‘s/ /\ /g’ | xargs -n 1 -I ‘{}’ mv {} /path/to/destdir/

  • http://ferdianto.com/ ferdhie

    pake shell ajah
    grep -v ‘^#’ test.m3u | sed ‘s/ /\\ /g’ | xargs -n 1 -I ‘{}’ mv {} /path/to/destdir/

  • http://ferdianto.com/ ferdhie

    kok di spam?

    grep -v ‘^#’ test.m3u | sed ‘s/ /\ /g’ | xargs -n 1 -I ‘{}’ mv {} /dest/dir

  • http://ferdianto.com/ ferdhie

    kok di spam?

    grep -v ‘^#’ test.m3u | sed ‘s/ /\\ /g’ | xargs -n 1 -I ‘{}’ mv {} /dest/dir

  • http://bayu.freelancer.web.id/ ariefbayu

    Bingung deh sama dua orang ini. Wong posting masuk kok dibilang spam.

  • http://bayu.freelancer.web.id/ silent

    Bingung deh sama dua orang ini. Wong posting masuk kok dibilang spam.