diff --git a/.gitignore b/.gitignore index ee4ec6a..49d3cf7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ venv *.pyc -output \ No newline at end of file +test_out +test_in \ No newline at end of file diff --git a/tools/copy.py b/tools/copy.py new file mode 100644 index 0000000..fec859a --- /dev/null +++ b/tools/copy.py @@ -0,0 +1,34 @@ +import uuid +import sys +import os +import argparse +import hashlib +import shutil +from progress.bar import Bar + +def argument_parsing(): + parser = argparse.ArgumentParser() + parser.add_argument("input_folder", help="the folder of your raws", type=str) + parser.add_argument("output_folder", help="the location of your website", type=str) + args = parser.parse_args() + + return args.input_folder, args.output_folder + +def main(): + input_folder, output_folder = argument_parsing() + files: list[str] = [os.path.join(input_folder, f) for f in os.listdir(input_folder)] + files = [f for f in files if os.path.isfile(f)] + with Bar("generating...", max=len(files)) as bar: + for file in files: + with open(file, 'rb') as f: + image_data = f.read() + file_extention: str = file.split(".")[-1] + file_name: str = hashlib.sha256(image_data).hexdigest() + path: str = os.path.join(output_folder, file_name) + if not os.path.exists(path): + os.makedirs(path) + shutil.copy2(file, os.path.join(path, file_name + "." + file_extention)) + bar.next() + +if __name__ == "__main__": + exit(main()) \ No newline at end of file