Created
June 10, 2016 18:16
-
-
Save milo2012/3581186780ffcc2cedc84331c77ce624 to your computer and use it in GitHub Desktop.
parseFileList.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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