old_contents: 
  # This script takes a snapshot of all of the source code files
  # that are autogenerated by the reposit SWIG module.
  
  import os
  import glob
  import shutil
  
  #ROOT_DIR = 'C:/Users/erik/Documents/repos/reposit/quantlib'
  ROOT_DIR = '/media/windows/linux/repos/reposit/quantlib'
  
  SUB_DIRS = (
      'QuantLibAddin2/qlo',
      'QuantLibAddin2/qlo/valueobjects',
      'QuantLibAddin2/qlo/serialization/create',
      'QuantLibAddin2/qlo/serialization/register',
      'QuantLibAddin2/AddinCpp',
  #    'QuantLibXL2/qlxl/functions',
  #    'QuantLibXL2/qlxl/register'
  )
  
  OUT_ROOT_DIR = './diffout'
  
  def deriveDir():
      i = 0;
      d = OUT_ROOT_DIR + "/d" + str(i)
      while os.path.exists(d):
          i += 1
          d = OUT_ROOT_DIR + "/d" + str(i)
      return d
  
  if not os.path.exists(OUT_ROOT_DIR):
      os.mkdir(OUT_ROOT_DIR)
  
  outDir = deriveDir()
  os.mkdir(outDir)
  print 'output directory is ' + outDir
  
  for subDir in SUB_DIRS:
      sourceDir = ROOT_DIR + '/' + subDir
      targetDir = outDir + '/' + subDir
      os.makedirs(targetDir)
      for f in glob.glob(sourceDir + '/*.?pp'):
          fileName = os.path.basename(f)
          print 'processing file ' + subDir + '/' + fileName
          shutil.copy(f, targetDir + '/' + fileName)
  
  
new_contents: 
  # This script takes a snapshot of all of the source code files
  # that are autogenerated by the reposit SWIG module.
  
  import os
  import sys
  import glob
  import shutil
  
  #ROOT_DIR = 'C:/Users/erik/Documents/repos/reposit/quantlib'
  ROOT_DIR = '/media/windows/linux/repos/reposit/quantlib'
  
  SUB_DIRS = (
      'QuantLibAddin2/qlo',
      'QuantLibAddin2/qlo/valueobjects',
      'QuantLibAddin2/qlo/serialization/create',
      'QuantLibAddin2/qlo/serialization/register',
      'QuantLibAddin2/AddinCpp',
  #    'QuantLibXL2/qlxl/functions',
  #    'QuantLibXL2/qlxl/register'
  )
  
  OUT_ROOT_DIR = './diffout'
  
  def deriveDir():
      i = 0;
      d = OUT_ROOT_DIR + "/d" + str(i)
      while os.path.exists(d):
          i += 1
          d = OUT_ROOT_DIR + "/d" + str(i)
      return d
  
  if not os.path.exists(ROOT_DIR):
      print "Error - the specified ROOT_DIR does not exist:\n\n" + \
          "    " + ROOT_DIR + "\n"
      sys.exit(1)
  
  if not os.path.exists(OUT_ROOT_DIR):
      os.mkdir(OUT_ROOT_DIR)
  
  outDir = deriveDir()
  os.mkdir(outDir)
  
  for subDir in SUB_DIRS:
      sourceDir = ROOT_DIR + '/' + subDir
      targetDir = outDir + '/' + subDir
      os.makedirs(targetDir)
      for f in glob.glob(sourceDir + '/*.?pp'):
          fileName = os.path.basename(f)
          print 'processing file ' + subDir + '/' + fileName
          shutil.copy(f, targetDir + '/' + fileName)
  
  print 'output directory is ' + outDir
  
  
subject: improve error handling in utility script