You are here

Playlist on USB Drives

6 posts / 0 new
Last post
arqbrulo
arqbrulo's picture
Offline
Last seen: 4 years 1 month ago
Joined: 2006-08-10 16:38
Playlist on USB Drives

I've been taking a lot from this site and it's users. Now it's time for me to give whatever I can to the community. First some info about this. I use Billy to play my music, and the playlist that it creates is very simple, it's just the path to my files. But since the drive letter changes from computer to computer, I created this vbs script. Here's what it does:
checks the first line of my playlist, splits the line, and reads the drive letter from it. Then checks the drive letter of the usb, if they don't match then it will replace the old drive letter with the new one. So here it is:

arrPath = Split(Wscript.ScriptFullName, "\")
drive = arrPath(0)
Const ForReading1 = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(drive & "\Documents\Billy\Playlist.txt", ForReading1)
For i = 1 to 1
objTextFile.ReadLine
Next
strLine = objTextFile.ReadLine
arrLine = Split(strLine, "\")
objTextFile.Close
if arrLine(0) = arrPath(0) Then
	Wscript.Quit
else 
	Const ForReading = 1
	Const ForWriting = 2

	Set objFSO = CreateObject("Scripting.FileSystemObject")
	Set objFile = objFSO.OpenTextFile(drive & "\Documents\Billy\Playlist.txt", ForReading)
	
	strText = objFile.ReadAll
	objFile.Close
	strNewText = Replace(strText, arrLine(0), arrPath(0))
	
	Set objFile = objFSO.OpenTextFile(drive & "\Documents\Billy\Playlist.txt", ForWriting)
	objFile.WriteLine strNewText
	objFile.Close
End if

If you want the script to read, lets say, the fourth line, change "For i = 1 to 1" to read "For i = 1 to 3". In other words, one line before the line you want to read. Or if you want to read the first line, delete "For i = 1 to 1" and "Next". Then create an exe using AutoIt or a bat file to run the script then start your music player.

Ryan McCue
Ryan McCue's picture
Offline
Last seen: 14 years 6 months ago
Joined: 2006-01-06 21:27
Sweet

Thanks, I'll add it to my drive Smile
Also, since you have reminded me, I'd like to say thanks for recommending Billy in the first place, it's a great player.
----
Ryan McCue
Current Fav. Songs:

  • Ballroom Blitz - The Misfits
  • Manic Monday - Cyndi Lauper
  • I Don't Like Mondays - The Boomtown Rats

"If you're not part of the solution, you're part of the precipitate."

Bahamut
Bahamut's picture
Offline
Last seen: 12 years 3 months ago
Joined: 2006-04-07 08:44
m3u and pls both support

m3u and pls both support relative paths...

Vintage!

Steve Lamerton
Steve Lamerton's picture
Offline
Last seen: 10 years 6 months ago
Developer
Joined: 2005-12-10 15:22
Could you not use,
Do While Not objTextFile.AtEndOfStream 
     objTextFile.ReadLine 
     //Process line
Loop 

to go through all of the lines in the playlist (note I am assuming that Billy puts one file per line here, I've never used it)

Yours

Steve Lamerton

My Blog

arqbrulo
arqbrulo's picture
Offline
Last seen: 4 years 1 month ago
Joined: 2006-08-10 16:38
Not sure

You have to excuse my ignorance. I really don't know much about scripts or codes (or anything related to the inner works of a program). I'm not sure how to implement what you are saying. Please explain. But, yes, Billy does put one file per line.
---------------
Marge: Homer, the plant called. They said if you don't show up tomorrow don't bother showing up on Monday.
Homer: Woo-hoo. Four-day weekend.

"In three words I can sum up everything I've learned about life: it goes on." -- Robert Frost
"In three words I can sum up everything I've learned about life: baby ain't mine." -- Adam Holguin

Steve Lamerton
Steve Lamerton's picture
Offline
Last seen: 10 years 6 months ago
Developer
Joined: 2005-12-10 15:22
Well,

basically the Do While loop goes through each line in the text file, so you could then process each line in the loop, I'll upload what I mean tomorrow.

Yours

Steve Lamerton

My Blog

Log in or register to post comments