Hello everyone. In short what I am trying to do is this:
Create a script that will prompt for a path. Then it will cycle through all the files and folders in that path searching for any files named "Folder.jpg" or "folder.jpg" (I'm not sure if it's case sensitive...). Then if it finds any files that have that name, I want to run this DOS command on them:
attrib -S -H
So here is what I have so far:
Can someone help me fill in the blanks as to what I am missing here? Also, some of the Folder.jpg files are hidden and system files (that's what the command is getting rid of).
Any help would be appreciated! Thanks
-Mark
Create a script that will prompt for a path. Then it will cycle through all the files and folders in that path searching for any files named "Folder.jpg" or "folder.jpg" (I'm not sure if it's case sensitive...). Then if it finds any files that have that name, I want to run this DOS command on them:
attrib -S -H
So here is what I have so far:
Code:
Dim fs, fil, fldr, strPath
Set fs = CreateObject("Scripting.FileSystemObject")
strPath = InputBox("Enter Path of folder", "Find File")
If strPath = "" Or fs.FolderExists(strPath) = False Then
MsgBox "Not a valid folder Path.", 64
WScript.Quit
End If
Set fldr = fs.GetFolder(strPath)
For Each fil In fldr.Files
If fil.Name = "Folder.jpg" Then
'starts a dos box and runs a command
Dim strCommand, objShell, objExec
strCommand = "attrib -S -H " & Chr(34) & fil.Path & Chr(34)
Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec(strCommand)
End If
Next
Can someone help me fill in the blanks as to what I am missing here? Also, some of the Folder.jpg files are hidden and system files (that's what the command is getting rid of).
Any help would be appreciated! Thanks
-Mark