From af712a22ab447be76d1b2a4bd32794a604017008 Mon Sep 17 00:00:00 2001 From: Audrey Aaliyah Jensen Date: Thu, 7 Sep 2023 09:01:49 -0500 Subject: [PATCH] allows passing an input path as argument --- Sandbox Scripts/extract.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sandbox Scripts/extract.py b/Sandbox Scripts/extract.py index 023714e..5e11fdf 100644 --- a/Sandbox Scripts/extract.py +++ b/Sandbox Scripts/extract.py @@ -13,11 +13,13 @@ import os import email from email import policy from multiprocessing import Pool +import sys EXTENSION = "eml" - +OUTPATH = "" def extract(filename): + print(filename) """ Try to extract the attachments from all files in cwd """ @@ -52,9 +54,10 @@ def extract(filename): if __name__ == "__main__": + path = sys.argv[1] or "" # let's do this in parallel, using cpu count as number of threads pool = Pool(None) - res = pool.map(extract, glob.iglob("*.%s" % EXTENSION)) + res = pool.map(extract, glob.iglob("%s*.%s" % (path, EXTENSION))) # need these if we use _async pool.close() pool.join()