Monday, April 2, 2012

cppl2f - bash- script to copy files from m3u- playlist

m3u. playlist on your player. Input parameters: self playlist and directory where we throw the music. I am using in conjunction with. exaile. There I had nagenerirovany playlists. Example of use:.

cppl2f playlist0000. m3u / media/KEEPMASS300/CONTENTS/MUSIC. 


cppl2f. - The name of the script, cast into. / bin. You all may be called by another. Do not forget to make the file executable:.

chmod x cppl2f. 


Listing script with comments:.



sh.




if [-z. '. $ 1. '. ] | | [-Z. '. $ 2. '. ].
then.
echo. 'usage:. $ 0. playlist. m3u destination_dir '.
else.
if [-f. '. $ 1. '. ].
then.
if [-d '$ 2' ].
then.

while read line.
do.
if echo. '. $ line. '. | Grep-q. ^.
then.

to. they do not carry useful information.
continue.
else.

freespace. = $ (df $ 2 | awk '{print. $ 4. } '| Sed' s / \\ ([0-9] * \\) \\ (. * \\) / \\ 1 / ').
filesize. = $ (du-k. '. $ line. '. | Sed 's / \\ ([0-9] * \\) \\ (. * \\) / \\ 1 / ').
if [. $ freespace. -gt. $ filesize. ].
then.
basename '$ line'.

cp. '. $ line. '. '. $ 2. '.
fi.
fi.
done. < $ 1.
echo. 'free space:. $ freespace. Kb '.
else.
echo. '. $ 2. isn't a valid destination directory. '.
fi.
else.
echo. '. $ 1. isn't a playlist file. '.
fi.
fi.

exit 0.

No comments:

Post a Comment