Created
July 18, 2014 18:09
-
-
Save mpdavis/2f32f18316641219670a 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 python | |
import os | |
import os.path | |
import shutil | |
import sys | |
def main(): | |
GOOGLE_DRIVE_DIR = "/Users/michael/Google Drive/Altitude Iowa Vids/" | |
TARGET_DIR = "/Users/michael/Pictures/Altitude Iowa/" | |
if not GOOGLE_DRIVE_DIR.endswith("/"): | |
GOOGLE_DRIVE_DIR = GOOGLE_DRIVE_DIR + "/" | |
if not TARGET_DIR.endswith("/"): | |
TARGET_DIR = TARGET_DIR + "/" | |
for dirpath, dirnames, filenames in os.walk(GOOGLE_DRIVE_DIR): | |
for filename in [f for f in filenames if f.lower().endswith(".dng")]: | |
if not dirpath.startswith(GOOGLE_DRIVE_DIR): | |
raise ValueError("Directory is not in the Google Drive directory.") | |
partial_dir = dirpath[len(GOOGLE_DRIVE_DIR):] | |
google_file = os.path.join(GOOGLE_DRIVE_DIR, partial_dir, filename) | |
target_file = os.path.join(TARGET_DIR, partial_dir, filename) | |
if not os.path.exists(target_file): | |
os.makedirs(os.path.join(TARGET_DIR, partial_dir)) | |
if not os.path.isfile(target_file): | |
shutil.copy(google_file, target_file) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment