""" List Document Saver
Usage : python ListDocSaver.py [options] [pathToRead]
Options :
-p, --path= The specific path of directory (or unit to read)
-h, --help show thi help
-d show debugging information while parsing
Example :
ListDocSaver.py -p /home/userName/ write into [definitepath]/ContenutoaaaaMMgg.txt the content of directory and subdirectory
Visit http://gli-artigli-della-lince.blogspot.com
"""
__author__ = "Aldo D'Offizi (aldo.doffizi@gmail.com)"
__version__= "$1.0$"
__date__ = "$Date: 2011/04/26 14:14:00 $"
__copyright__= "Copyright (c) 2011 Aldo D'Offizi"
__licence__= "Python"
import sys
import getopt
import os
defaultPath='/home/username/Documenti/DVD-CD/'
def main(argv):
try:
opts, args=getopt.getopt(argv,"hp:d",["help", "path="])
except getopt.GetoptError:
usage()
sys.exit(2)
for opt, arg in opts:
if opt in ("-h", "--help"):
usage()
sys.exit()
elif opt == '-d':
global _debug
_debug=1
elif opt in ("-p", "--path"):
popolaFileLog(arg)
def usage():
print __doc__
def popolaFileLog(directoryRif):
ls=directoryRif.split('/')
ls.reverse()
pathFile=defaultPath + 'Contenuto%s.txt' % (ls[0])
logFile= open(pathFile,'w')
for path, subdirs, files in os.walk(directoryRif):
for name in files:
logFile.writelines(os.path.join(path, name))
logFile.writelines('\n')
logFile.close()
if __name__== "__main__":
main(sys.argv[1:])