批量修改脚本名称

这里举例批量将脚本名的"_"替换成"-"

'************************************************************************************************************************
'Description:
'

'Assumptions:
'  There is no unsaved test currently open in QuickTest.
'  For more information, see the example for the Test.SaveAs method.
'  When QuickTest opens, it loads the add-ins required for the test.
'  For more information, see the example for the Test.GetAssociatedAddins method.
'
'
'************************************************************************************************************************
 
Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtTest 'As QuickTest.Test ' Declare a Test object variable
Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable 
Dim scriptsArray ' All scritps to be executed
Dim scriptPath ' Absolute Path of all scripts
Dim reportResult ' Status report of all scripts


TC_Path = "C:\TestCases\"
New_Path = "C:\TestCases\"

Set fso = CreateObject("Scripting.FileSystemObject")
Set parentFolders = fso.GetFolder(TC_Path)
Set fc = parentFolders.SubFolders

Set fso = Nothing

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object

qtApp.Launch ' Start QuickTest

qtApp.Visible = False ' Make the QuickTest application visible 

' Set QuickTest run options

qtApp.Options.Run.CaptureForTestResults = "OnError"

qtApp.Options.Run.RunMode = "Fast"

qtApp.Options.Run.ViewResults = False

For Each f in fc
'MsgBox TC_Path&f.name
 qtApp.Open TC_Path&f.name, True ' Open the test in read-only mode
 newfilename = Replace(f.name, "_", "-")
 'MsgBox newfilename
 qtApp.Test.SaveAs New_Path & newfilename ' Save the test

Next

'MsgBox reportResult

qtApp.Quit

Set qtResultsOpt = Nothing ' Release the Run Results Options object

Set qtTest = Nothing ' Release the Test object

Set qtApp = Nothing ' Release the Application object

MsgBox "Completed!!!!!!!"

posted @ 2012-09-13 17:26  dushuai  阅读(302)  评论(0编辑  收藏  举报