I have a script that goes using os.walk to go down a directory structure and matching files by extension and copies files to another location.
This is what i have for the file copy:
sourceDir=sys.argv[-2].rstrip("/")
destDir=sys.argv[-1].rstrip("/")
//copy code
So i would just call:
python mycode.py ~/a/ ~/b/
What i want to do is add an optional argument switch that will also match by a search pattern:
python mycode.py --match "pattern" ~/a/ ~/b/
In my code i would add this extra if:
if "--match" in sys.argvs:
#try reference the string right after --match"
for root, dir, files... etc
So to be precise, how can i find "pattern" if --"match" is in sys.argvs? New to python, so any help would be greatly appreciated.
Thanks!