Quote:
Originally Posted by SaswatPadhi
Hi,
Thanx for reporting. :)
There was a typo at this line :Set objColFolders = objFolder.Folders
It should read :Set objColFolders = objFolder.SubFolders.
...
Hi,
I adapted the code for the list folder and
all sub-folders but the error below appears when I run the file:
Line: 26
Char: 5
Error: Expected statement
Code: 800A0400
Source: Microsoft VBScript compilation error
I need to list the
all filenames in each folder too but, I'm
beginner in VBScript! Can you help me?
What I have to do?
Adapted Code:
Code:
On Error Resume Next
Const WINDOW_HANDLE = 0
Const BIF_EDITBOX = &H10
Const BIF_NONEWFOLDER = &H0200
Const BIF_RETURNONLYFSDIRS = &H1
Set objShell = CreateObject("Shell.Application")
Set wshShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strPrompt = "Please select the folder to process."
intOptions = BIF_RETURNONLYFSDIRS + BIF_NONEWFOLDER + BIF_EDITBOX
strTargetPath = wshShell.SpecialFolders("MyComputer")
strFolderPath = Browse4Folder(strPrompt, intOptions, strTargetPath)
Set objNewFile = objFSO.CreateTextFile(strFolderPath & "\ListaMP3.txt", True)
Set objFolder = objFSO.GetFolder(strFolderPath)
'MY ADAPTATION START HERE
Set objColFolders = objFolder.SubFolders
:AllFolders
For Each tfolder In objColFolders
objNewFile.WriteLine(tfolder.Name)
objColFolders = tfolder.SubFolders
GoTo AllFolders
Next
'END HERE
objNewFile.Close
Function Browse4Folder(strPrompt, intOptions, strRoot)
Dim objFolder, objFolderItem
On Error Resume Next
Set objFolder = objShell.BrowseForFolder(0, strPrompt, intOptions, strRoot)
If (objFolder Is Nothing) Then
Wscript.Quit
End If
Set objFolderItem = objFolder.Self
Browse4Folder = objFolderItem.Path
Set objFolderItem = Nothing
Set objFolder = Nothing
End Function