I want to delete all the documents(.doc) files from my computer, for that I know how to get the list of sub folders from a folder, but not how to get the list of folders from the root directory(Ex C:)
subfoldersInFolder = folder.subFolder
Gives all the subfolders of a folder. but supposedly that I want all the folders from C:,
Set colDrives = objFSO.Drives
For Each objDrive in colDrives
objDrive.subFolder //doesn't work
Next
PHP using scandir() to find folders in a directory The scandir function is an inbuilt function that returns an array of files and directories of a specific directory. It lists the files and directories present inside the path specified by the user.
For Each objFolder In objFSO.GetFolder("C:\").SubFolders
WScript.Echo objFolder.Path
Next
' or...
For Each objFolder In objFSO.GetDrive("C:").RootFolder.SubFolders
WScript.Echo objFolder.Path
Next
Edit: sundar nataraj Сундар has asked that I go into more detail.
This is a basic For
loop that iterates the SubFolders
collection. The SubFolders
property is only available for a Folder
object. You can get a Folder
object for the root in a number of ways. Here are two examples:
GetFolder()
function to retrieve a root folder.RootFolder
property of a Drive
object.I've added a WScript.Echo
statement in each example to demonstrate the use of the objFolder
variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With