Created
June 3, 2010 17:15
-
-
Save gfontenot/424170 to your computer and use it in GitHub Desktop.
Python script to crawl the contents of your dropbox folder for Conflicted Copies
This file contains 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 | |
# encoding: utf-8 | |
""" | |
CleanDB.py | |
Created by Gordon on 2010-06-03. | |
Copyright (c) 2010 Gordon Fontenot. All rights reserved. | |
""" | |
import sys | |
import os | |
import re | |
from shutil import move | |
dropboxPath = "~/Dropbox" | |
dropboxPath = os.path.expanduser(dropboxPath) | |
conflictedPath = dropboxPath + "/!Conflicted Copies/" | |
p = re.compile("'s Conflicted Copy", re.IGNORECASE) | |
p_ignore = re.compile("!Conflicted Copies", re.IGNORECASE) | |
def main(): | |
if not os.path.exists(conflictedPath): | |
os.mkdir(conflictedPath) | |
for root, dirs, files in os.walk(dropboxPath): | |
if not (p_ignore.search(root)): | |
for name in files: | |
if p.search(name): | |
# print "Conflicted Copy Found!\n" + root + "\n" + name | |
f = os.path.join(root, name) | |
try: | |
move(f, conflictedPath) | |
except: | |
print "Error moving "+ f | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment