Simple shell script to create playlists from file structure
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!
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!
Code:
#!/bin/bash # mkpls.sh - Create a playlist from a bunch of files. # # Information how to use it # ========================= # Invocation: # $ mkpls.sh "[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] mkpls.sh has to be invoked like # this: # $ mkpls.sh "/home/[user]/music/[ARTIST]/[NAME OF CD]" # If the execution was successfull, you will get following output, printed on # the console: # # ~/[ARTIST] ~/[ARTIST] # ~/[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/.." popd
Total Comments 0