Last active
October 13, 2020 04:21
-
-
Save evanlu14/4be8c29325ca0859a8edfb89db710a10 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/env python3 | |
import sys | |
import argparse | |
import os | |
import shutil | |
def main(): | |
parser = argparse.ArgumentParser(description='Copy exported google photos into one directory') | |
parser.add_argument('-i', '--input-dir', help='Input directory') | |
parser.add_argument('-o', '--output-dir', help='Output directory') | |
args = parser.parse_args() | |
if args.input_dir is None: | |
parser.error('Input directory is mandatory') | |
if not os.path.exists(args.output_dir): | |
os.makedir(args.output_dir) | |
cnt = 0 | |
for root, dirs, files in os.walk(args.input_dir): | |
for name in files: | |
if name.endswith(".jpg"): | |
src_path = os.path.join(root, name) | |
dest_path = os.path.join(args.output_dir, name) | |
if not os.path.exists(dest_path): | |
shutil.copyfile(src_path, dest_path) | |
cnt += 1 | |
if cnt % 100 == 0: | |
print("status: Copied {} photos".format(cnt)) | |
print("Successful copy {} photos".format(cnt)) | |
if __name__ == "__main__": | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment