#1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2013
    Location
    Roanoke, VA
    Posts
    23
    Rep Power
    0

    VBS Script - Edit xml files in folder - wildcards/string ?


    Is there a way to edit all xml files in a folder based on a certain criteria? The file names would change throughout the day so I would need to use wildcards or string, I suppose. I have this example that works if I have the name of the file.
    I would run the vbs script several times a day using windows scheduler. Thanks for any help!

    Code:
    Set xmlDoc = _
      CreateObject("Microsoft.XMLDOM")
    
    xmlDoc.Async = "False"
    xmlDoc.Load("C:\Scripts\DRTEST.xml")
    
    Set colNodes=xmlDoc.selectNodes _
      ("/VIDEOLIST/CLIPATTRIBUTES" & _
       "[FILESIZE > '500']/FILESIZE")
    
    For Each objNode in colNodes
       objNode.Text = ("400")
    Next
      
    xmlDoc.Save "C:\Scripts\DRTEST.xml"
  2. #2
  3. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2013
    Location
    Roanoke, VA
    Posts
    23
    Rep Power
    0
    So the above code allowed me to open up a file, edit it, then save it. That worked with an exact file name. I am trying to do this to all xml files in a folder, but the file names would change daily so I wouldn't know the file names. The below code gets me closer, but the files that are saved are all blank. Nothing in them. Any thoughts?

    Code:
    Set ObjFSO = CreateObject("Scripting.FileSystemObject")
    ObjStartFolder = "C:\Scripts"
    Set Objfolder = ObjFSo.GetFolder(objstartfolder)
    
    Set ColFiles = Objfolder.files
    For Each Objfile in ColFiles
    strFileName = objfile.name
    
    Dim xmlDoc
    
    set xmlDoc = CreateObject("Microsoft.XMLDOM")
    xmlDoc.async = "false"
    xmlDoc.load(strFileName)
    
    Set colNodes=xmlDoc.selectNodes _
      ("/VIDEOLIST/CLIPATTRIBUTES" & _
       "[FILESIZE > '500']/FILESIZE")
    
    For Each objNode in colNodes
       objNode.Text = ("400")
    
    Next
    xmlDoc.Save ("C:\Scripts\tests\"& strFileName)
    Next

Similar Threads

  1. Replies: 2
    Last Post: September 20th, 2009, 02:41 AM
  2. Replies: 0
    Last Post: February 17th, 2009, 10:26 AM
  3. Replies: 1
    Last Post: October 20th, 2005, 06:27 AM
  4. Edit folder permissions???
    By ncozzolino in forum ASP Development
    Replies: 7
    Last Post: September 19th, 2005, 09:03 AM
  5. copy files from shared folder to the local C:\ folder
    By kiran_karnati in forum Visual Basic Programming
    Replies: 1
    Last Post: September 27th, 2004, 04:34 PM

IMN logo majestic logo threadwatch logo seochat tools logo