Skip to content

Instantly share code, notes, and snippets.

@milo2012
Created June 10, 2016 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milo2012/3581186780ffcc2cedc84331c77ce624 to your computer and use it in GitHub Desktop.
Save milo2012/3581186780ffcc2cedc84331c77ce624 to your computer and use it in GitHub Desktop.
parseFileList.py
#!/usr/bin/python
import argparse
import sys
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-f', action='store', help='[file containing directory listing]')
if len(sys.argv)==1:
parser.print_help()
sys.exit(1)
options = parser.parse_args()
fileList=[]
if options.f:
with open(options.f) as f:
content = f.readlines()
fullPath = ''
dirName=""
for i in content:
i = i.strip()
if "Directory of" in i:
i = i.replace('Directory of ','')
dirName = i
if dirName not in fileList:
fileList.append(dirName)
else:
if (" AM " in i or " PM " in i) and ('<DIR>' not in i):
filename = dirName+i.split(" ")[-1]
if filename not in fileList:
fileList.append(filename)
for x in fileList:
print x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment