Tuesday, August 18, 2009

Recursive search in vbscript.

It was this particular thing in vbscript which was lurring me from many days. I had written a small script for downloading Test Cases from Quality Center to Excel. QC 9.5 provides this as in built functionality but we had some old systems where in we had to pull all existing cases in Excel. The code was ready and I found that it needed exact path from QC logical folder structure to find all cases within it. There was a dire need to search within the given path to find all sub folders and test cases within them.

There was another requirement to replace one particular string from many script files stored on a server where quality center was installed. I had to replace all scripts which get saved on qc file system which had a particular string present in it. All test cases of type QUICK_TEST get saved with Script.mts file holding the actual textual part of script.

Here is a snippet to find particular file type (e.g.: Here i have searched for .mts file type as it was our requirement) within given folder and it searches in all sub folders present in it:

strDir = "D:\rohan\test"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objDir = objFSO.GetFolder(strDir)RecursiveFunc (objDir)

Sub RecursiveFunc(Dir_Passed)
For Each Item_File In Dir_Passed.Files
If LCase(Right(CStr(Item_File.Name), 3)) = "mts" Then
wscript.Echo Dir_Passed & "\" & Item_File.Name
End If

For Each Item_Fldr In Dir_Passed.SubFolders
'wscript.Echo Item_Fldr.Name & " recursed"
RecursiveFunc (Item_Fldr)
End Sub


mts to mov convert said...

Nice post.

Tony Adams said...

mts file converter mov convert avchd mts to iPhone mov
it seems that we have similar interesting.

mary Brown said...

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Online Training from India. or learn thru ASP.NET Essential Training Online . Nowadays Dot Net has tons of job opportunities on various vertical industry.
JavaScript Online Training from India