Tuesday 30 December 2014

How to find the solution file paths from root folder using VBScript

Option Explicit 'force all variables to be declared
Const ForWriting = 2
Dim objFSO 'File System Object
Dim CurrentDirectory,objTS,localpath


set objFSO = CreateObject("Scripting.FileSystemObject")
CurrentDirectory = objFSO.GetAbsolutePathName(".")
Set objTS = objFSO.CreateTextFile(CurrentDirectory&"\SVNExport.txt", True)
localpath = WScript.Arguments.item(1) 'C:\Praveen'
Call Recurse(localpath)
objTS.Close()

Sub Recurse(strFolderPath)
    Dim objFolder
    Set objFolder = objFSO.GetFolder(strFolderPath)
    Dim objFile
    Dim objSubFolder

    For Each objFile In objFolder.Files
        'only proceed if there is an extension on the file.
        If (InStr(objFile.Name, ".") > 0) Then
            'If the file's extension is "pfx", write the path to the output file.
            If (LCase(Mid(objFile.Name, InStrRev(objFile.Name, "."))) = ".sln") Then _
                objTS.WriteLine(objfile.Path)
        End If
    Next

    For Each objSubFolder In objFolder.SubFolders
        Call Recurse(objSubFolder.Path)
    Next
End Sub

No comments:

Post a Comment