You are not logged in Log in Join
You are here: Home » Members » dylanr » Move Objects Between Folders

Log in
Name

Password

 

Move Objects Between Folders

There are many reasons you might want to move objects between folders using a Python Script. You might, for example, want to archive older instances.

Assume the following directory structure:

    Items
      Current
      Archive

We want to move older items from Current to Archive when some trigger event happens. To do so, we can create a Python Script in Items/Current called archive_old which contains the lines:

cb_copy_data = context.manage_cutObjects(ids)
return context.Items.Archive.manage_pasteObjects(cb_copy_data)

You can verify the Script by testing it on a known ID. To make it more useful, create a DTML method to step through the Current directory, determine which Items need archival, and call archive_old, passing it a list of IDs as a parameter.