Heroes, I'm a newbie.
VBS
Coding purpose: Create an M3U playlist file in the original directory for all music files (MP3 + WMA) under a certain folder. Here is the code, but there are errors. Can you tell me why?
'======== Get MP3 or WMA Playlist.vbs ======
Dim fso, s, folder,
'Create connection and get the current folder directory of the script
Set fso = createobject("scripting.filesystemobject")
folder = Left(Wscript.ScriptFullName, len(Wscript.ScriptFullName) - len(Wscript.ScriptName))
'Call procedure to output information
SeekLastFolder folder
Set folder = Nothing
Set fso = Nothing
Sub SeekLastFolder (ByVal thePath)
Set fso = CreateObject("scripting.filesystemobject")
'Why does it always prompt an error below, saying the path is not found. I don't understand where the mistake is. Please give me some advice!
Set curFolder = fso.getfolder(thePath)
'Judge if there are files
If curFolder.Files.count > 0 Then
For Each Mefile In curFolder.Files
'Judge if the file is a music file
If Right(Mefile.name, 3) = "mp3" Or Right(Mefile.name, 3) = "wma" Then
'Call function to make Winnamp list
Makem3u(Mefile.name)
End If
Next
End If
'Judge if there are subfolders in the folder
If curFolder.SubFolders.count > 0 Then
For Each Subfolder In curFolder.SubFolders
'Enter subfolder
NewFolder = curfolder & Subfolder
SeekLastFolder NewFolder
Next
End If
End Sub
'Make list
Function Makem3u(MeFileName)
Set Wm3u = fso.CreateTextFile (curFolder & "\" & "00.PlayList.m3u")
s = s & MeFilename & VbCrLf
Wm3u.WriteLine s
Wm3u.Close
Set Wm3u = Nothing
End Function
'=========== End ===================================
The file list to be generated:
====== 00.PlayList.m3u ======
101.Enter Sandman.mp3
102.Creeping Death.mp3
103.Harvester of Sorrow.mp3
104.Welcome Home (Sanitarium).mp3
105.Sad but True.mp3
.
.
.
.
110.Ain't my B_tch.mp3
========== end =======
The numbers are all song names!!
Paste another "Search Files with VBS Script.vbs" file, which can run online.
My above script has a lot in common with this file script, basically the same!
But why can his run and mine can't?
I basically followed his code!!!
[ Last edited by kich on 2007-1-31 at 12:18 PM ]
VBS
Coding purpose: Create an M3U playlist file in the original directory for all music files (MP3 + WMA) under a certain folder. Here is the code, but there are errors. Can you tell me why?
'======== Get MP3 or WMA Playlist.vbs ======
Dim fso, s, folder,
'Create connection and get the current folder directory of the script
Set fso = createobject("scripting.filesystemobject")
folder = Left(Wscript.ScriptFullName, len(Wscript.ScriptFullName) - len(Wscript.ScriptName))
'Call procedure to output information
SeekLastFolder folder
Set folder = Nothing
Set fso = Nothing
Sub SeekLastFolder (ByVal thePath)
Set fso = CreateObject("scripting.filesystemobject")
'Why does it always prompt an error below, saying the path is not found. I don't understand where the mistake is. Please give me some advice!
Set curFolder = fso.getfolder(thePath)
'Judge if there are files
If curFolder.Files.count > 0 Then
For Each Mefile In curFolder.Files
'Judge if the file is a music file
If Right(Mefile.name, 3) = "mp3" Or Right(Mefile.name, 3) = "wma" Then
'Call function to make Winnamp list
Makem3u(Mefile.name)
End If
Next
End If
'Judge if there are subfolders in the folder
If curFolder.SubFolders.count > 0 Then
For Each Subfolder In curFolder.SubFolders
'Enter subfolder
NewFolder = curfolder & Subfolder
SeekLastFolder NewFolder
Next
End If
End Sub
'Make list
Function Makem3u(MeFileName)
Set Wm3u = fso.CreateTextFile (curFolder & "\" & "00.PlayList.m3u")
s = s & MeFilename & VbCrLf
Wm3u.WriteLine s
Wm3u.Close
Set Wm3u = Nothing
End Function
'=========== End ===================================
The file list to be generated:
====== 00.PlayList.m3u ======
101.Enter Sandman.mp3
102.Creeping Death.mp3
103.Harvester of Sorrow.mp3
104.Welcome Home (Sanitarium).mp3
105.Sad but True.mp3
.
.
.
.
110.Ain't my B_tch.mp3
========== end =======
The numbers are all song names!!
Paste another "Search Files with VBS Script.vbs" file, which can run online.
My above script has a lot in common with this file script, basically the same!
But why can his run and mine can't?
I basically followed his code!!!
[ Last edited by kich on 2007-1-31 at 12:18 PM ]
Attachments

