Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have all my music, unsorted in /home/blah/Music/. It's in random folders, which doesn't matter for me though since Banshee takes care of everything. I have a large playlist containing a good 2/3 of my music. How can I copy all the mp3 files listed in the playlist into a new folder?

Note: I am not trying to export a playlist, but copy the mp3s listed in the playlist.

share|improve this question

6 Answers 6

up vote 12 down vote accepted

I did this with rhythmbox, make a folder on your desktop give it a name. now find the play list you like when the music list shows click on one of the songs and hold ctrl+a high light the hole list now drag and drop it in to the folder on your desktop. this should make copy's of your music. you can also try clementine music player it has some tools to help you export.

http://www.clementine-player.org/

share|improve this answer
4  
+1 This works with Banshee as well. –  Sabacon May 18 '11 at 17:55
1  
Guess it doesn't get more intuitive. In Banshee you can make smart playlists, this lets you copy exactly what you want. –  The Negative Shape May 19 '11 at 10:03

Found the solution, works with any media player.

  1. Export your playlist to a m3u file. I called it playlist.m3u

  2. Open a terminal in the folder where you have saved the file.

  3. Copy & paste this:

    sed "s/#.*//g" < playlist.m3u | sed "/^$/d" | while read line; do cp "${line}" '/path/to/output/folder/'; done
    

Remember to change the path to your desired output folder.

Note: Terminal will not give any output whilst files are copied, just be patient ;)

share|improve this answer
1  
Awesome! I wish I could +1 it thousand times. –  Pratyush Jul 14 '12 at 15:55
    
This is the easiest way, if your player Banshee. Thanks! –  nitins Nov 25 '13 at 8:24

Good question, this is a well needed feature, It is strange how so few media players have it.

Here is a method you can try, it may have limitations in your case especially if your playlist is very large, write a data CD to disk with the files from the playlist save the resulting .iso image where you want and then extract it.

Here are the steps:

  • Select your playlist on the left. Make sure all Artists is selected in the top right pane.

  • select all tracks in playlist in bottom right pane.

  • Right click and click Write CD.

Brasero should start with all the tracks ready to be burned to CD, it will by default want to Write an audio CD, now there will likely be so many tracks that will not possibly fit on an audio CD so the next step is to change the brasero project.

  • Click the project menu in brasero, then select New Data project in the flyout menu.

You will be asked "Do you want to discard the file selection or add it to the new project?"

  • Click the Keep file selection button.

Brasero is now ready to write an Iso image with all your playlist's files to any location you choose.

  • Click the burn button on the bottom right, choose your location and name the iso image, the write process will be fairly fast as no transcoding or normalizing is done.

  • Right click the .iso image and extract it, this will create a folder with the files.

If you wish you can go ahead and just burn the Cd as backup or if you need to give a copy to someone.

See screenshots:

Main Banshee window

Banshee write CD  menu

Banshee write CD menu

Brasero Audio CD project Window

Brasero Audio CD project, Change this to a Data project

Brasero project selection

The Brasero Menus showing how to change project type

Brasero data cd project

The data project that can handle a fair amount of mp3s

share|improve this answer

Thanks The Negative Shape for this great solution! I've modified it so that files are renamed according to their position in the playlist.

sed "s/#.*//g" < playlist.m3u | sed "/^$/d" | while read line; do (( COUNTER++ )); filename="${line##*/}"; cp "${line}" "/path/to/output/folder/$COUNTER - $filename"; done
share|improve this answer

I'll also leave my script as it may be useful for somebody. https://gist.github.com/CRImier/9777606

import os
import shutil

directory_name = "playlist/"
playlist_name = "playlist.m3u"

f = open(playlist_name, "r")
files = []
for line in f:
    line = line.strip().strip("\n").strip("\r")
    if line and not line.startswith("#"):
        files.append(line)
dir_contents = os.listdir(directory_name)
for file in files:
    try:
        filename = os.path.basename(file)
        if filename not in dir_contents:
            shutil.copy(file, "playlist/")
            print filename
        else:
            print ".", #File already there
    except Exception as e:
        print str(e)

It's pure Python and doesn't copy songs twice when run multiple times. Hope this helps somebody =)

share|improve this answer

Here is a script I use to copy files from the /home/user/playlist.m3u file into the /home/user/export/ folder as long as your actual files are in /home/user/Music/ if not just change the one line in the script.

#!/bin/bash
m3u=$(sed /#.*/d "/home/user/playlist.m3u"|sed 's/\.\.\/\.\./\/home\/user/g');

echo "$m3u" | while read line; do
    newFile=$(echo $line| sed 's/\/home\/user\/Music\//\/home\/user\/export\//');
    newPath=$(echo "$newFile" | grep -o .*\\/);

    mkdir -p "$newPath";
    cp "$line" "$newFile";  
done;
exit 0;

The difference with dragging banshee entries into a folder is that this script will keep the hierarchy of your /artists/albums/track.mp3 or whatever hierarchy you have to reflect exactly whatever m3u playlist you create. So this way no duplicates possible and every track is in its former place.

I made this because my phone only has MTP and it's a bit hazy under Ubuntu. Plus banshee will synch my android very chaotically. So I almost HAVE to use this to wifi transfer my export folder.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.