Recursion/Looping through subfolder names using FSO

  • Hey all I am trying to recurse through a set of subfolders and issue HTTP GET commands

    The core of the script was posted by another site members and works great when I give it a static folder. The problem is the folder name and number of folder in the directory changes. The folders are located on a NAS so I need to use a static path.

    If this was recursing through files in a directory I would use FSO and say 'For Each fl in fc' but when I tried that it failed (see below).

    Thanks in advance.

    --------------------

    Working no recursion of subfolders

    Function Main()

      

     dim strURL, oBrowser

     dim serverPath

     dim folderPath

     serverPath = "machine name"

     folderPath = "path to folder\"

     strURL =serverPath & folderPath

    set oBrowser = CreateObject("Microsoft.XMLHTTP")

     oBrowser.Open "GET" , strURL , false , "" , ""

     oBrowser.send

     msgbox oBrowser.responsetext

     set oBrowser = nothing

     Main = DTSTaskExecResult_Success

    End Function

    -------------------------------

    Attempted recurion- not working

    Function Main()

     dim folderPath

     dim strURL, oBrowser

     dim serverPath

     Dim fso, fl, fc, fold

     Set fso = CreateObject("Scripting.FileSystemObject")

     Set fold = fso.GetFolder(folderPath) 

     serverPath = "machine name"

     folderPath ="path to folder\"

     Set fc=f.Files 

     strURL =serverPath & folderPath

    For Each fl in fc

    set oBrowser = CreateObject("Microsoft.XMLHTTP")

     oBrowser.Open "GET" , strURL , false , "" , ""

     oBrowser.send

     msgbox oBrowser.responsetext

     set oBrowser = nothing

     Main = DTSTaskExecResult_Success

    End Function

     

  • Hmmm. Looks like you've got a bug in your code...

     Set fso = CreateObject("Scripting.FileSystemObject")

     Set fold = fso.GetFolder(folderPath) 

     serverPath = "http://pe-ocr.apa.org/fulltext/psq_html_conversion/?"

     folderPath = "conversionPath=psq\Journals_proofing\SGML_to_be_converted\"

    Should probably be...

     Set fso = CreateObject("Scripting.FileSystemObject") 

     serverPath = "http://pe-ocr.apa.org/fulltext/psq_html_conversion/?"

     folderPath = "conversionPath=psq\Journals_proofing\SGML_to_be_converted\"

     Set fold = fso.GetFolder(folderPath) 

    You are trying to get the folder before you've specified a value for folderPath. Don't know if this is the source of your problem, but it looks like a problem in any case.

     

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply