Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Blogs > invalidid
User Name


Rate this Entry

Simple shell script to create playlists from file structure

Posted 03-01-2010 at 12:28 PM by invalidid
Updated 12-03-2013 at 04:15 PM by invalidid

Hi everybody!
In my first post on this blog I want to publish something simple but useful for guys who prefer to use applications like xine, mplayer or totem for playing music. It's a bash script, which creates playlists using the unix tool "find". Basic documentation can be found in the header of the script file.

I hope you find it useful and comfortable. Have fun with it!

# - Create a playlist from a bunch of files.
# Information how to use it
# =========================
# Invocation:
# $ "[FULL PATH]"
# This will create a playlist file with ".pls" as extension. This file has the
# same name like the given directory, except its extension and is stored on the
# same place like the given directory. 
# Setup example:
# It is useful in cases, where following directory structure is used:
# /home/[user]/music/[ARTIST]/[NAME OF CD]/[NR][NAME OF SONG].[EXT]
# And to create the playlist for [NAME OF CD] has to be invoked like
# this:
# $ "/home/[user]/music/[ARTIST]/[NAME OF CD]"
# If the execution was successfull, you will get following output, printed on 
# the console:
# ~/[ARTIST]
# This is because of the commands "pushd" and "popd", which will save and 
# restore the current working directory. 
# If you find a bug, don't hesitate to mail me.
# Have fun!

outfile=`basename "$1"`.pls

pushd .

cd /
touch "$1/$outfile"
find "$1/" -type f | grep -v "$outfile" | sort > "$1/$outfile"
mv "$1/$outfile" "$1/.."
Views 2812 Comments 0
« Prev     Main     Next »
Total Comments 0




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

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