1. Prompt user to input path to some folder on system
2. Get a folder object to represent that folder
3. Get a files collection to represent all the files in the folder the user has selected
4. Check number of files in your collection. If its 0 generate message box that folder does not contain files. If it does contain files, generate message box that indicates number of files.
This is what I came up with:
Code:Option Explicit Dim fso, folderid, yourfiles, yourfolder 'First, I need a file system object Set fso = WScript.CreateObject("scripting.filesystemobject") 'Get a drive letter from the user. folderid = InputBox("Please enter a path to a folder.","Information","C:\") If fso.FolderExists(folderid) Then Set yourfolder = fso.GetFolder(folderid) Set yourfiles = yourfolder.files MsgBox "Your folder (" & folderid & ") exists." Else MsgBox "Your folder (" & folderid & ") does not exist." End if If fso.FolderExists(folderid) Then MsgBox "Your folder (" & folderid & ") contains " & yourfiles.Count & " folders." Else MsgBox "Your folder " & folderid & " has NOT been found." End if If yourfiles.count = 0 Then MsgBox "Your folder does not contain any files." Else MsgBox "Your folder contains " & yourfiles.Count & " files!" End if


Reply With Quote

Bookmarks