LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-16-2013, 01:01 AM   #1
dluco
LQ Newbie
 
Registered: Aug 2013
Location: British Columbia, Canada
Distribution: Crunchbang, Ubuntu, Slackware
Posts: 14

Rep: Reputation: Disabled
Create m3u playlist of all .flac files


Hi,
I've been attempting to create a m3u playlist that contains every flac file in a certain directory (say Music/). I've tried using EasyTag to do this, but it generates a playlist with all files (mp3, ogg, etc.). I'm sure there is a way to do this with a (relatively) simple script, but I'm not sure how to go about it.

NOTE: I'd like to have the relative paths of the flac files in the playlist

Thanks in advance!
 
Old 08-16-2013, 03:06 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392
Assuming your directory structure looks something like this:
Code:
/path/to/Music
/path/to/Music/Artist 1
/path/to/Music/Artist 1/Album 1
/path/to/Music/Artist 1/Album 2
/path/to/Music/Artist 2
/path/to/Music/Artist 2/Album 1
You can try either of these:
Code:
cd /path/to/Music
find "Artist 1" -type f -iname "*flac" > new.playlist.m3u

# or, no need to cd first

find "/path/to/Music/Artist 1" -type f -iname "*flac" | sed 's/\/path\/to/Music//' > /path/to/Music/new.playlist.m3u
BTW: Are you really sure about the relative path? This would limit the location of the playlist files to (in this case) /path/to/Music? Using an absolute path would be better, this way you can store the playlist.m3u files anywhere.
 
1 members found this post helpful.
Old 08-16-2013, 03:14 AM   #3
Dafydd
Member
 
Registered: Oct 2008
Posts: 344

Rep: Reputation: 29
With a text editor, open a 'm3u' file. Note the structure on the path to the music file.

Then study this script and adapt it to your needs.
Code:
#!/bin/bash

target=html`date +"%F_%k"` ##file name

bodyheader="
<body bgcolor=\"#efb321\" text=\"#f8c99f\" link=\"#006666\" vlink=\"#003300\">"

echo "$bodyheader" >> "$target"

headerline="
<p align=\"center\" style=\"line-height: 100%; margin-top: 0; margin-bottom: 0\">&nbsp;</p>
<table border=\"1\" width=\"90%\" bordercolor=\"#f8c99f\" bordercolorlight=\"#efb321\" bordercolordark=\"#f8c99f\" bgcolor=\"#a95205\" id=\"table1\">"

echo  "$headerline" >> "$target"


for filename in *.gif *.jpg  *.JPG *.png *.jpeg;  ##list all images in directory

  do
  if [ -f "$filename" ]
    then

	 imageline="
<td align=\"center\"> <p style=\"margin-top: 0; margin-bottom: 0\"> <img border=\"0\" src=\"$filename\"></a></p> </td>"

	
	   echo "$imageline" >> "$target"  ##write to disk.
	   
    else
        :
    fi
	   
  done
I use this script to create a table of several hundred images to cut and paste into an 'HTML' file.

I see you only have 6 posts but since you are asking for scripts I assume you do have some linux experience. This should give you the concept you need.

Ask questions if you need.
D
 
1 members found this post helpful.
Old 08-16-2013, 05:08 AM   #4
cascade9
Senior Member
 
Registered: Mar 2011
Location: Brisneyland
Distribution: Debian, aptosid
Posts: 3,753

Rep: Reputation: 934Reputation: 934Reputation: 934Reputation: 934Reputation: 934Reputation: 934Reputation: 934Reputation: 934
Quote:
Originally Posted by dluco View Post
I've been attempting to create a m3u playlist that contains every flac file in a certain directory (say Music/). I've tried using EasyTag to do this, but it generates a playlist with all files (mp3, ogg, etc.). I'm sure there is a way to do this with a (relatively) simple script, but I'm not sure how to go about it.
You can do it with easytag.

Open ther folder with all the files in easytag.

File-> Sort List By Propetry-> Ascending File Type. All .flac files are now sorted togther. Highlight all the flac files.

Misc-> Write Playlist.

Last edited by cascade9; 08-17-2013 at 04:45 AM. Reason: typo
 
1 members found this post helpful.
Old 08-16-2013, 12:16 PM   #5
dluco
LQ Newbie
 
Registered: Aug 2013
Location: British Columbia, Canada
Distribution: Crunchbang, Ubuntu, Slackware
Posts: 14

Original Poster
Rep: Reputation: Disabled
@druuna Both of your suggestions make valid playlists and are far simpler than anything I've seen. I wanted to use relative paths so that the playlist & files could be moved to a portable media player, but I'm not sure if I should be using the absolute instead. I suppose I could run the script/playlist generation commands in the media player once the files are already there.

@Dafydd Thanks for an advanced way to get the files and I'll have to study your example to see what's happening.

@cascade9 Perfect! I figured that there was a way to do it.

Now that I have several ways to create a playlist, I wanted to ask what the benefits of using an extended m3u playlist are (if any)? I understand the format, but I'm not sure how to make one without doing it completely manually (or using a program like EasyTag).
 
Old 08-16-2013, 01:14 PM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392
Quote:
Originally Posted by dluco View Post
@druuna Both of your suggestions make valid playlists and are far simpler than anything I've seen.
Yep, its bar-bones. All the other stuff in the m3u playlist files I've seen are comments, which do not seem to be used by mplayer / audacious (my choice of players). The needed info about the file playing can be fetched from the file itself (at least by mplayer/audacious).

Quote:
wanted to use relative paths so that the playlist & files could be moved to a portable media player, but I'm not sure if I should be using the absolute instead. I suppose I could run the script/playlist generation commands in the media player once the files are already there.
If the play-lists are placed in Music and you use relative paths the it is portable (doesn't matter if /path/to/Music is used or /another/path/to/Music). If you use absolute then the complete dir structure must be the same on the other device. I do think using relative is the way to go in this case.
 
1 members found this post helpful.
Old 08-16-2013, 11:54 PM   #7
Darth Maul
LQ Newbie
 
Registered: Aug 2013
Distribution: PClinuxOS 2013.7 KDE
Posts: 28

Rep: Reputation: Disabled
This works for me with a playlist of mp3 files. To find flac files use the find command like so

Code:
find /path-to-Music/ -iname "*.flac" > myfavorites.m3u
Then use mplayer to play the playlist like so

Code:
mplayer -playlist myfavorites.m3u
For media players, I usually copy over the files and create the playlist from the device. These devices will have there own procedures or structure/format for making playlists.

The procedure above is to make a playlist of music files to be played on the computer using mplayer.

Last edited by Darth Maul; 08-17-2013 at 12:26 AM.
 
1 members found this post helpful.
Old 08-17-2013, 01:15 AM   #8
dluco
LQ Newbie
 
Registered: Aug 2013
Location: British Columbia, Canada
Distribution: Crunchbang, Ubuntu, Slackware
Posts: 14

Original Poster
Rep: Reputation: Disabled
Thank you everyone for the assistance!
I believe I'll now be able to create a playlist by a variety of equally quick and simple methods.
Marking thread as "SOLVED".
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
recreating m3u files from Ipod apolinsky Linux - Software 0 02-09-2011 05:10 PM
how to create an archive from a m3u playlist bricedebrignaisplage Linux - General 1 01-17-2009 09:53 PM
How to create a archiv from my audio-cd with .flac and .cue files like eac ToK Linux - Desktop 1 09-11-2006 10:23 AM
what are .m3u and .sfv files? servnov General 3 09-18-2004 10:36 PM
create m3u file from the console ziggis-soft Linux - Newbie 1 07-25-2004 10:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration