Created
January 14, 2018 17:18
-
-
Save GeorgeNance/1619287e6d856370b5894be76d24f392 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
import os | |
import sys | |
import shutil | |
import time | |
COPY_DIR = "/Users/George/Camera" | |
MOUNT_DIR = os.path.join("/Volumes", "REBEL1") | |
PHOTO_DIR = "/DCIM/100CANON/" | |
def check_if_mounted(): | |
return os.path.ismount(os.path.realpath(MOUNT_DIR)) | |
print("Starting import"); | |
dst_path = COPY_DIR + time.strftime("/%Y-%m-%d/") | |
video_path = dst_path +"video/"; | |
raw_path = dst_path +"raw/"; | |
os.makedirs(video_path) | |
os.makedirs(raw_path) | |
if os.path.isdir(MOUNT_DIR + PHOTO_DIR): | |
if os.listdir(MOUNT_DIR + PHOTO_DIR) != []: | |
files = os.listdir(MOUNT_DIR + PHOTO_DIR) | |
file_count = len(files) | |
i = 0 | |
status = "" | |
while i < file_count: | |
status = "Skipped" | |
#video | |
if files[i].endswith(".MOV"): | |
shutil.copy(MOUNT_DIR + PHOTO_DIR + files[i], video_path +files[i]) | |
status = "Copied" | |
#raw | |
if files[i].endswith(".CR2"): | |
shutil.copy(MOUNT_DIR + PHOTO_DIR + files[i], raw_path +files[i]) | |
status = "Copied" | |
i+=1 | |
print ("{0}/{1} {2}: {3}".format(i,file_count,status,files[i])); | |
cmd_out = os.popen("pumount " + MOUNT_DIR).read() | |
if len(cmd_out) > 0: | |
print("Error unmounting disk") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment