
- #Microsoft scripting runtime references for mac how to
- #Microsoft scripting runtime references for mac plus
- #Microsoft scripting runtime references for mac windows
It doesn’t matter if there are subfolders in the folder the script doesn’t really care.Ī recursive function, by contrast, does care: it will keep working until it has done everything you asked of it, and more. The script we showed you above lists all the files in a folder and then stops. That might not make much sense, but think of it this way.

(Yes, we do seem to be promoting the book quite a bit today, don’t we?) Basically a recursive function is a function that can automatically call itself as many times as needed.
#Microsoft scripting runtime references for mac windows
We’re not going to explain recursion here for more details, check out this portion of the Microsoft Windows 2000 Scripting Guide. To do that you need to use a recursive script.
#Microsoft scripting runtime references for mac plus
Getting back a list of all the files in a folder plus all the files in any subfolders of that folder can be a bit trickier. In other words, getting back a list of all the files in a folder is trivial.
#Microsoft scripting runtime references for mac how to
For a more complete rundown of the FileSystemObject and how to use it, you might want to check out the Script Runtime Primer in the Microsoft Windows 2000 Scripting Guide. But we could do a lot more than that for example, we could report back the DateCreated property or the Size property. Because you asked how to get a list of all the files in a folder, all we do is echo the name of the file. (But- and this has important implications for your second question – this collection does not include files found in any subfolders of C:\Scripts.) At this point the rest is child’s play: we can now use a For Each loop to loop through the collection of files and – if we choose – do something to each and every one. That gives us back a collection consisting of all the files found in the folder. If we wanted to bind to, say, the Windows folder, all we’d have to do is change the path accordingly, something we do by assigning a different value to objStartFolder: objStartFolder = “C:\Windows”Īfter we’ve connected to the folder, we then create a reference to the Files property using this command: Set colFiles = objFolder.Files We create an instance of the FileSystemObject, and then we use the GetFolder method to bind to folder C:\Scripts.

Set objFolder = objFSO.GetFolder(objStartFolder)Īs you can see, there really isn’t much to this. This script reports back the file name of all the files found in the folder C:\Scripts: Set objFSO = CreateObject(“Scripting.FileSystemObject”) Let’s start with the easy one: a script that simply lists all the files in a folder.

Your questions are the perfect lead-in to that explanation. We also promised that, in today’s column, we’d explain how we managed to get a list of all the files in a folder in the first place. Yesterday we showed everyone a script that changed all the files in a folder from read-only to read-write. Hey, Scripting Guy! How can I use a script to show me all the files in a folder? And then how can I modify that script so it shows me all the files in any subfolders of that folder?
