Windows Command Script to Create a WinAmp Playlist

07/21/07

Permalink 08:03:01 am, by dave Email , 457 words, 421 views   English (US)
Categories: Windows Scripting, Batch Scripts

Windows Command Script to Create a WinAmp Playlist

I spend a lot of time listening to my mp3 collection. I have always just told WinAmp to play a folder, but this gets problematic if you have music in multiple locations.

So I threw together this Windows command file to get the contents of a directory and write the full path of those files to an output file, in m3u format. By default the script will append to the end of whatever output file that is passed in. The script expects to be looking for mp3 files, but you can change that by updating the FILEEXT variable to whatever you want it to be.

[More:]



@echo off

echo --------------------------------------------------------------
echo -
echo - %~f0
echo - A Windows command script that creates a WinAmp playlist.
echo - The expected output file extension is .m3u
echo -
echo - Copyright 2007, Dave Moats
echo -
echo - This script is provided 'as-is', without any express or implied warranty.
echo - In no event will the author be held liable for any damages arising from
echo - the use of this script.
echo -
echo - Permission is granted to anyone to use this script for any purpose,
echo - including commercial applications, subject to the following restrictions:
echo -
echo - The origin of this script must not be misrepresented; you must not
echo - claim that you wrote the original script. If you use this script,
echo - an acknowledgment in the documentation is requested - shown below:
echo -
echo - Portions Copyright 2007, Dave Moats (http://www.davemoats.com/).
echo -
echo --------------------------------------------------------------

::-----------------------------------------------------------------
::- make sure we have some arguments to work with
::-----------------------------------------------------------------
if "%1"=="" goto NOARG1
if "%2"=="" goto NOARG2

::-----------------------------------------------------------------
::- does the folder we are going to enumerate exist?
::-----------------------------------------------------------------
if NOT exist %1 goto NOFOLDER

::-----------------------------------------------------------------
::- make sure we can use case insensitive comparisons when checking
::- the file extensions
::-----------------------------------------------------------------
setlocal enableextensions

set FILEEXT=.mp3

::-----------------------------------------------------------------
::- loop through the source folder and create a play list
::-----------------------------------------------------------------
for /f "tokens=1 delims=|" %%j in ('dir %1 /b') do (
   if /I %%~xj EQU %FILEEXT% (
      echo %1\%%j>>%2
   ) else (
      echo %1\%%j is not an mp3 file.
   )
)

endlocal

goto JOBDONE

:NOFOLDER
echo --------------------------------------------------------------
echo - Unable to find folder that was to be processed.
echo -
echo - Usage: %~f0 [path to folder] [path to playlist file]
echo --------------------------------------------------------------
goto JOBDONE

:NOARG1
echo --------------------------------------------------------------
echo - The required folder path was not passed in, please choose
echo - the folder you want to create a playlist for and resubmit
echo - your request
echo -
echo - Usage: %~f0 [path to folder] [path to playlist file]
echo --------------------------------------------------------------
goto JOBDONE

:NOARG2
echo --------------------------------------------------------------
echo - The required path to the playlist to be created was not
echo - passed in, please choose a playlist name and path and
echo - resubmit your request.
echo -
echo - Usage: %~f0 [path to folder] [path to playlist file]
echo --------------------------------------------------------------

:JOBDONE



Did you like this post? If so, Share it!  del.icio.us digg reddit slashdot this article Facebook Twitter MySpace Email



Pingbacks:

No Pingbacks for this post yet...

This post has 5 feedbacks awaiting moderation...

Scripts

This is somewhere I can post interesting snippets as I come across them. Hopefully some folks out there will find this helpful.

Search

Follow Me:

Misc

Who's Online?

  • Guest Users: 2

powered by b2evolution free blog software