oXygen XML Editor

Directory Listing

Python

Chris Bayes gave me a piece of javascript a long time ago, which provides a recursive directory listing, in XML. I neither understood it, nor could I amend or adapt it. But boy did I use it. Again and again. When I moved to Linux, I missed it, so with (more than a little) help from Uche Ogbuji (of 4Suite), I have produced a Python version. Usable on Linux or Windows, more flexible than Chris's version. Here it is. Type in python dirlist.py --help to see the usage statement.

26 June 05. Updated to enable no recursion. Something I needed for one job. I found it useful, you may too.

Options include

-d --date Add date attribute
-s --size Add size attribute
-m --mdsum Add md5sum attribute
-n --norecurse Do not recurse into directories
-p --path Path to directory to process
-o output file.

Omit the output option to generate output to stdout. -p is required (the directory to search). Providing the md5sum (checksum) is there simply because I needed a way of finding duplicate files. Example output is after the form shown below.

      <directory
      name="/files/python/disksearch/disksearch-1.0.0/po">
        <file date="2004-12-21" sz="5Kb" name="disksearch.pot" md5="4251e51fc7e12cf981ecf2168e949ce8"/>
        <file date="2004-12-21" sz="5Kb" name="de.gmo" md5="9d84603b8428d3c6bae8153f4fba7ed1"/>
        <file date="2004-12-21" sz="7Kb" name="de.po" md5="88c46ba75a1c5c652c82e2da37a9d9a3"/>

Directories are properly nested etc. Enjoy