target_path = sys.argv[1]
dest_file = os.path.join(os.getcwd(), sys.argv[2])
ignore_list = ['...', ...]
# Dir files
dir_list = [f for f in os.listdir(target_path)
if os.path.isfile(f) and not f in ignore_list]
# Iterate files to pack
for idx, f in enumerate(dir_list):
mode = 'w' if idx == 0 else 'a'
with open(f, 'r') as file:
output = open(dest_file, mode)
output.write(file.read()+'\n')
output.close()
$ python what-ever.py [target_dir] [dest_file]_ http://en.wikipedia.org/wiki/%3F:#Python
_ http://www.dalkescientific.com/writings/NBN/python_intro/command_line.html
_ http://magazine.redhat.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/
_ http://stackoverflow.com/questions/898669/how-can-i-detect-if-a-file-is-binary-non-text-in-python
_ http://docs.python.org/library/mimetypes.html
_ https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
_ http://www.crockford.com/javascript/jsmin.html