View Single Post
Old 2nd January 2013, 23:24   #4
mjbrown
Senior Member
 
Join Date: Aug 2001
Posts: 114
OK, thanks. I will rely on a script to generate the playlist separately, then.

Here is what I'm currently doing in a Windows command shell to generate a playlist of all the music files in a given folder tree:

code:
chcp 65001 && dir T:\music /b /s | findstr /e /l ".mp3 .flac .m4a .wav .wma .ogg .mp2" | findstr /e /l /v ".lnk" > playlist.m3u8


Of course, replace T:\music with the actual folder to scan (or list of folders, space-separated). You can omit any filename extensions that you don't want to look for.

Explanation:
chcp 65001 sets UTF-8 mode, which isn't well supported for displaying text in the command shell (you'll probably get bogus "out of memory" errors), but it works correctly when redirecting output to a file as we're doing here. If you need to keep working in the same window after this, run chcp again to change to your normal codepage (e.g. chcp 437 in the U.S.)

dir X /b /s recursively lists the contents of folder X, outputting one complete file path or folder path per line. Wrap X in double quotes if it contains spaces. You can specify multiple folders if you want, separated by spaces.

findstr /e /l "X Y Z" extracts just the lines which end (/e) with the literal string (/l) X, Y, or Z.

findstr /e /l /v "X" extracts the lines which don't (/v) end (/e) with the literal string (/l) X.

&& means do the next command if the previous one succeeded.

| means pipe the output of the last command to the next one.

> X means write the output of the last command to the file X instead of the console.
To automate the playlist generation in Windows Vista and up, open the Task Scheduler (just start typing task in the Start menu's search box) and create a new task with a 'Start a program' action. Enter any name and description you want. Set the trigger time so that it will run daily, just a couple minutes into the future so you can test it right away. Set the program to cmd.exe and the arguments to /C "foo" where foo is the command line as given above. "Start in" should be the path of the folder where you want playlist.m3u8 to be created (I use the path of my Desktop), or you can leave it blank and specify the full path in the arguments. If it works properly, you'll briefly see a command shell window open with the output of chcp (65001 is UTF-8), and then it will close once the playlist is generated. If all goes well, go back into the task's properties and change the trigger schedule to whatever you really want.
mjbrown is offline   Reply With Quote