Paperclip Hand

July 30, 2009

Processing Winamp generated .m3u playlists for the Blackberry Bold

Filed under: Blackberry, Code, Windows — papercliphand @ 11:54 am

When you use Winamp to manage the music on your Blackberry Bold you run into a problem whereby the .m3u playlists that Winamp generates include full paths instead of relative paths. I use the first of the two scripts to “process” the Winamp generated .m3u playlists on my Blackberry Bold. The second batch file will remove any orphaned empty folders.


ProcessM3U.vbs

' VB Script Document
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Editable Variable - this should be the relative path from the script to the location of the .m3u files
' include the preceding and trailing \
' eg. if the script lives in f:\ and the playliosts live in f:\blackberry\music\ then use \blackberry\music\
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dim filefolder : filefolder = "\blackberry\music\"

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Get list of files to process
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
on error resume next
dim scriptpath : scriptpath = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName)))
dim ffile
dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
dim fldr : Set fldr = fso.GetFolder(scriptpath & filefolder)
dim fc : Set fc = fldr.Files
For Each ffile in fc
If ffile.size > 0 then ' ignore empty files
if lcase(right(ffile.name, 4)) = ".m3u" then ' only process .m3u files
call processFile(filefolder, ffile.name)
end if
end if
Next
If Err.Number <> 0 Then
msgbox("ERROR: " & Err.Number & " - " & Err.Source & " - " & Err.Description)
Err.clear
end if
on error goto 0
msgbox("Completed...")

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' processFile() - process file
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function processFile(filefolder, filename)
processFile = true
on error resume next
dim strText
dim fs
dim textStreamObj1
Set fs = CreateObject("Scripting.FileSystemObject")
Set textStreamObj1 = fs.OpenTextFile(scriptpath & filefolder & filename, 1)
strText = textStreamObj1.ReadAll
strText = Replace(strText, filefolder, "", 1, -1, 1)
textStreamObj1.close
Set textStreamObj1 = fs.OpenTextFile(scriptpath & filefolder & filename, 2)
textStreamObj1.WriteLine strText
textStreamObj1.Close
If Err.Number <> 0 Then
msgbox("ERROR , processFile : ERROR : " & Err.Number & " - " & Err.Source & " - " & Err.Description)
Err.clear
end if
on error goto 0
end function


RemoveEmptyfolders.bat

@echo off
color c0
echo.
echo.*******************************************************************************
echo.
echo delete empty folders
echo.
echo.*******************************************************************************
echo.
cd Blackberry\Music
for /f "usebackq delims=" %%d in (`"dir /ad/b/s | sort /R"`) do rd "%%d"
echo.
echo.*******************************************************************************
echo.
echo completed
echo.
echo.*******************************************************************************
echo.
pause


Just copy and paste the code above into two files and save using the names provided (or feel free to make up your own).
Save these 2 files to the root of your memory card (for me it appears in Windows Explorer as F:\ )
Once you have finished syncing your Bold with Winamp then just run the 2 files to change the playlists into relative paths that the Blackberry will recognize and clean up any orphaned empty folders.

Advertisement

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.