masschange_title.py
## Script (Python) "rename"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
# Example code:
# Import a standard function, and get the HTML request and response objects.
from Products.PythonScripts.standard import html_quote
request = container.REQUEST
RESPONSE = request.RESPONSE
substitution = [
('‘', "'"),
('’', "'"),
('“', '"'),
('”', '"')
]
def replace_html(obj):
text = obj.Title()
tosubs=False
for (a,b) in substitution:
if text.find(a)>=0:
tosubs = True
text = text.replace(a,b)
if tosubs:
obj.setTitle(text)
return tosubs
for year in range(1960, 2008):
print "testing %s" % str(year)
dir=context.get(str(year))
if dir:
#try:
if True:
#dir.setTitle(str(year))
l = dir.listFolderContents()
for i in l:
done=[]
if replace_html(i):
print "Changed title of %s" % i.getId()
i.setExcludeFromNav(True)
i.reindexObject()
print " done"
#except:
# print " error "
# pass
else:
print " not found"
return printed