Populate a folder with symbolic links to files listed in an m3u playlist.

(IFS=$'\n'; ln -sf $(awk '((NR % 2) != 0 && NR > 1) {print "prefix" $0}' list.m3u) target_folder)
This command will place symbolic links to files listed in an m3u playlist into a specified folder. Useful for uploading playlists to Google Music. prefix = The full path prefix to file entries in your .m3u file, if the file paths are relative. For example, if you have "Music/folder/song.mp3" in your list.m3u, you might want to specify "/home/username" as your prefix. list.m3u = Path to the playlist target_folder = Path to the target folder in which you would like to create symlinks

1
By: lxe
2011-09-25 16:45:28

What Others Think

Here's a windows batch file version: @echo off REM %1 = m3u file, %2 = target path chcp 65001 for /f "delims=|; skip=1" %%I in (%1) do if not exist "%2%%~pI" mkdir "%2%%~pI" for /f "delims=|; skip=1" %%I in (%1) do mklink "%2%%~pI%%~nI%%~xI" "%%I"
mtone · 463 weeks and 6 days ago
This probably works well with most m3u playlist, but I've encountered many that are formatted more simply, i.e. just a text file with each file listed on a new line. This command skipped the first, second and then every second file listed in m3u playlists of that simple type. Removing the test at the beginning of awk fixed that problem for me. (IFS=$'\n'; ln -sf $(awk '{print "prefix" $0}' list.m3u) target_folder)
jazzcannibal · 445 weeks and 1 day ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: