add import script for image folders

This commit is contained in:
Sanj 2012-04-23 17:54:17 +05:30
parent 3437e65089
commit d83b8dc03e

22
urbstudio/urb/imports.py Normal file
View File

@ -0,0 +1,22 @@
from models import *
from django.core.files import File
from glob import glob
def importFile(filePath, project):
f = File(open(filePath))
pi = ProjectImage()
pi.project = project
pi.image = f
pi.caption = ''
pi.save()
print "%s saved" % filePath
return
def doDir(dirpath, project):
for f in glob("%s/*" % dirpath):
importFile(f, project)
print "all done"
return