Answered by:
wild character folder names

Question
-
Hi,
I've a folder heirarchy like below :
c:\root\oa
c:\root\ob
c:\root\oc
c:\root\od
c:\root\LDB
c:\root\LDB2
c:\root\LDB2010-12-12
c:\root\LDB2011-01-12
C:\root\0.5.1
c:\root\0.5.2
c:\root\0.5.3
c:\root\0.5.4
c:\root\0.5.5
below is the script to iterate the folders and call specific routine on few folders of my interest.
Am interested in pass the folders oa,ob,oc,od,0.5.5 as an argument to one of the subroutine.
===========================================================================
installFolder = "C:\root\"Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFold = objFS.GetFolder(installFolder)Set colSubfolders = objFold.Subfolders
For Each objSubfolder in colSubfolders
If objSubfolder.Name = "LDB" Then
Wscript.Echo "found the folder and skipping!!!!!!"ElseIf objSubfolder.Name = "0.5.1" Then
Wscript.Echo "found the folder and skipping!!!!!!"
ElseIf objSubfolder.Name = "0.5.2" Then
Wscript.Echo "found the folder and skipping!!!!!!"
ElseIf objSubfolder.Name = "0.5.3" Then
Wscript.Echo "found the folder and skipping!!!!!!"
ElseIf objSubfolder.Name = "0.5.4" Then
Wscript.Echo "found the folder and skipping!!!!!!"
Else
Wscript.Echo "processessing the other folders !!"
installFolder = installFolder & objSubfolder.Name
Call AddACEToFile("Everyone",installFolder,"FULL") ' this is the routine where am passing the folder of my interest as a second parameter.
installFolder = "C:\root\" ' resetting to pick correct folder name
End IfNext
===========================================================================What am looking for is similar to comparing the folder name with wildcharacters , like
------------------------------------------------------------------------------------------------------
If objSubfolder.Name = "LDB?" Then
Wscript.Echo "found the folder and skipping!!!!!!"
------------------------------------------------------------------------------------------------------
where i can skip further processing. The folder names starting with LDB are not fixed , hence looking for an alternative / best way to deal with.
Hope am clear in explaining the plight.Any help is greatly appreciated.
Thanks,
Narci
NarciWednesday, January 26, 2011 12:50 PM
Answers
-
Hi MasmoEka,
try this:
If VBA.Left(objSubfolder.Name,3) = "LDB" Then Wscript.Echo "found the folder and skipping!!!!!!" End if
Please 'Mark as Answer' if I helped. This helps others who have the same problem!- Proposed as answer by Dennis Hemken Tuesday, February 1, 2011 9:26 AM
- Marked as answer by MasmoEka Tuesday, February 1, 2011 11:46 AM
Wednesday, January 26, 2011 1:57 PM -
Hi Dennis,
Thank you very much , It worked !!
When used VBA.Left straight away , got runtime error ( Object required :'VBA').
But used without that it went off smoothly.If Left(objSubfolder.Name,3) = "LDB" Then Wscript.Echo "found the folder and skipping!!!!!!" End if
Cheers,
Narci- Marked as answer by MasmoEka Wednesday, January 26, 2011 2:41 PM
Wednesday, January 26, 2011 2:41 PM
All replies
-
Hi MasmoEka,
try this:
If VBA.Left(objSubfolder.Name,3) = "LDB" Then Wscript.Echo "found the folder and skipping!!!!!!" End if
Please 'Mark as Answer' if I helped. This helps others who have the same problem!- Proposed as answer by Dennis Hemken Tuesday, February 1, 2011 9:26 AM
- Marked as answer by MasmoEka Tuesday, February 1, 2011 11:46 AM
Wednesday, January 26, 2011 1:57 PM -
Hi Dennis,
Thank you very much , It worked !!
When used VBA.Left straight away , got runtime error ( Object required :'VBA').
But used without that it went off smoothly.If Left(objSubfolder.Name,3) = "LDB" Then Wscript.Echo "found the folder and skipping!!!!!!" End if
Cheers,
Narci- Marked as answer by MasmoEka Wednesday, January 26, 2011 2:41 PM
Wednesday, January 26, 2011 2:41 PM