Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement