Created
July 13, 2015 10:52
-
-
Save evildmp/e33e247fd0b9ab76ef46 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 shutil, os | |
from ds_store import DSStore | |
PATH_TO_TRASH = '/Users/divio/.Trash/' # for my disk | |
# PATH_TO_TRASH = '/Volumes/untitled/Trash/' # for the backup disk | |
PATH_TO_DS_STORE = PATH_TO_TRASH + '.DS_Store' | |
filelist = [] | |
usable_files = 0 | |
unusable_files = 0 | |
google_files =0 | |
try: | |
with DSStore.open(PATH_TO_DS_STORE, 'r+') as store: | |
total_files = len(store) | |
for data in store: | |
filelist.append(data) | |
except Exception, e: | |
print '- error: %s' % str(e) | |
total_files = len(filelist) | |
for obj in filelist: | |
if isinstance(obj.value, basestring): | |
usable_files += 1 | |
if "Users/divio/Google" not in obj.value: | |
continue | |
else: | |
print "- unexpected file: %s %s" % (obj, obj.value) | |
unusable_files += 1 | |
continue | |
google_files += 1 | |
if obj.code == 'ptbL': # and 'FA_LARGE_BG_200dpi_FLAT.psd' in obj.filename: | |
#if obj.code == 'ptbL' and 'test_gdrive_restore' in obj.filename: | |
print "+ moving --> from: %s | to: /%s | code: %s" % (obj.filename, obj.value, obj.code) | |
# try: | |
# shutil.move(PATH_TO_TRASH + obj.filename, '/' + obj.value) | |
# except (OSError, IOError, shutil.Error), e: | |
# pass | |
# print '- error moving %s to %s: %s' % (obj.filename, obj.value, e) | |
# if "already exists" in e.message: | |
# # os.remove(PATH_TO_TRASH + obj.filename) | |
# cmd_rm = "rm " + PATH_TO_TRASH + obj.filename | |
# os.system(cmd_rm) | |
else: | |
print "meh" | |
pass | |
print "Total:", total_files | |
print "filelist:", len(filelist) | |
print "usable_files:", usable_files | |
print "unusable_files:", unusable_files | |
print "google_files:", google_files |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment