Skip to content. Skip to navigation

ICTP Portal

Sections
You are here: Home notes on site structure and other plone tricks plone-tricks massrename_from_smart_folder.py
Personal tools
Document Actions

massrename_from_smart_folder.py

## Script (Python) "anto"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=src_topic,destination
##title=
##
## Warnings:
##  Doesn't print, but reads 'printed' variable.
##
# Import a standard function, and get the HTML request and response objects.
from Products.PythonScripts.standard import html_quote
#from zope.app.traversing.api import getParent

request = container.REQUEST
RESPONSE =  request.RESPONSE


# Cerca le news selezionate dallo smart folder 'antoniotest', le sposta
# in /prizes/News/test/YYYY con YYYY = anno, preso dal path della
# news, directory che eventualmente viene creata
dst=container
for i in destination.split('/'):
    if i != '': dst = dst[i]

src = container
for i in src_topic.split('/'):
    if i != '': src = src[i]


for i in src.queryCatalog():
    obj = i.getObject()
    p = obj.getPhysicalPath()[2:-1]
    x=container
    for pp in p:
        x = x[pp]
    print "Moving %s to %s " % (p, dst.getPhysicalPath())
    dst.manage_pasteObjects(x.manage_cutObjects([iobj.getId()]))


return printed

Powered by Plone This site conforms to the following standards: