def main(): usage = "usage: %prog [options] arg" parser = OptionParser(usage) parser.add_option("-d", "--inputdirectory", action="store", dest="indir") parser.add_option("-f", "--mergedfilename", action="store", dest="file", help="Filename for merged file") parser.add_option("-o", "--outputdirectory", action="store", dest="outdir", default="~/", help="Default directory: "+abspath(expanduser('~/'))) (options, args) = parser.parse_args() if not options.indir: parser.error('Input directory not provided') if not options.file: parser.error('Output merged filename not provided') sourcedirectory = options.indir mergedfilename = options.file mergeddirectory = abspath(expanduser(options.outdir)) filegroup = files( info(sourcedirectory).listfullpathfiles() ) filegroup.mergeinto(join(mergeddirectory,mergedfilename)) print "%s/%s" % (mergeddirectory,mergedfilename)