Created
April 24, 2015 13:15
-
-
Save patroqueeet/381aa5ceca59de02669e to your computer and use it in GitHub Desktop.
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
In [11]: while True: | |
for t in Thumbnail.objects.all(): | |
fname = os.path.basename(t.name) | |
dname = os.path.dirname(t.name) | |
h.join(root, dname)):.isfile(os.path.join(root, dname, fname)) and os.path.exists(os.path | |
for x in listdir(os.path.join(root,dname)): | |
if x[3:] == os.path.basename(t.name): | |
e, x[3:]) print "renaming", os.path.join(root,dname,x), os.path.join(root,dname | |
)) os.rename(os.path.join(root,dname,x), os.path.join(root,dname, x[3:]) | |
time.sleep(3) |
Final code:
from easy_thumbnails.models import Thumbnail
while True:
for t in Thumbnail.objects.all():
fname = os.path.basename(t.name)
dname = os.path.dirname(t.name)
if not os.path.isfile(os.path.join(root, dname, fname)) and os.path.exists(os.path.join(root, dname)):
for x in os.listdir(os.path.join(root,dname)):
if x[3:] == os.path.basename(t.name):
print "renaming", os.path.join(root,dname,x), os.path.join(root,dname, x[3:])
os.rename(os.path.join(root,dname,x), os.path.join(root,dname, x[3:]))
time.sleep(3)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
steal crumbled code from here...