Friday, October 27, 2006

Build XML Directory Structure

I've hacked together a little VBScript utility that will generate an Xml representation of a directory structure which you can download here. I looked around for something that already did this and came across Pat Coleman's DIR2XML utility. It provided a basis for what I needed but there were a couple of things I had to tweak - it generated a "flat" listing of all files and it produced an XHTML document via an XSL transform. Pat did a lot of the heavy lifting with the recursive directory scanning and getting file version information.

My bldDirXml.vbs does the following:

  1. Generates a nested Xml containing <folder> and <file> tags.
  2. Supports a "flattened" mode [-f] which pulls the information up into attributes of the folder or file tag instead of child elements.
  3. Generates a unique id for each folder and file.

To run it, use the following command: cscript bldDirXml.vbs "folderPath" [outputFilename] [-f]

All the usual disclaimers apply - it's a pretty brute force approach, not heavily tested, your mileage may vary, hold your nose if you look at the code, etc.

Enjoy!

Original post

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.