Use Alfresco folder rules to perform admin tasks


Folder rules are ordinarily used to initiate tasks when files are created or updated, but they can also be a convenient way to manage admin or migration tasks.  For example, you might need to perform bulk changes to properties of files.

Create a folder rule

To create a rule for a folder, choose ‘Manage Rules’ for the folder.

Choose 'Manage Rules' as above to create rules for a folder

‘Manage Rules’  to create rules for a folder

Example folder rule

The following is a folder rule that I used after migrating data into Alfresco using Cyberduck and WebDAV.  Choose ‘Items are updated’ for a rule that you want to run immediately.

Example rule to set all JPEG files to type 'fieldphoto'

Rule to set all JPEG files under the folder to type ‘fieldphoto’

Note that if you want to process files in subfolders, you will need to choose ‘Run rules for this folder and its subfolders’ – even though you have ticked ‘Rule applies to subfolders’ above.

Run rules for the folder and sub-folders

Run rules for the folder and sub-folders

Note that when you click ‘Run Rules’, ALL the enabled rules for the folder are run, so you need to disable all rules that you don’t want to run.  In the example below, only the ‘Create thumbnails’ rule will run, as the other rules have been disabled.


Rules for the Fieldobs folder – rules 1, 2, 3 and 5 are disabled

Scripts – extending the power of folder rules

There are many types of tasks that you can choose when defining a folder rule, but you can extend these choices even further by creating scripts in the ‘Scripts’ folder under the ‘Data Dictionary’ folder.  All of the scripts in this folder that have the extension ‘.js’ are listed when you choose ‘Execute script’ in your folder rule.

Alfresco scripts folder

All scripts stored in the ‘Scripts’ folder can be run within folder rules

The are many useful sample scripts in this folder.  ‘example test script.js.sample’ is a good script to start with – it shows ways of accessing the properties of each file/subfolder – for example …

// test accessing current document properties and modifying them
var docname =,'.')); = "12345 " +;;

// modify the parent space name = + " 1";;

// test accessing document content
var content = document.content;

// update the content by appending a string
document.content = content + "\r\nHere is another line added from a script!";

Further information

My follow-up blog – Using javascript console to create a folder rule script

The Alfresco Wiki (although officially superseded) has good Javascript API examples –

Alfresco JavaScript API reference –

Note that the javascript in the folder rules runs on the Alfresco server and the API that is used to access properties of documents, photos, etc. is sometimes referred to as the  ‘Alfresco Repository JavaScript API’.  Do not confuse this with the ‘Alfresco Share JavaScript API’ which runs on the client – ie. in the user’s browser.  The following section in the official docs explains the various programming interfaces to Alfresco –

Order of the Bee – an independent organisation of the Alfresco community. Web-site includes good technical and non-technical posts and other information, focussed mainly on Alfresco Community Edition (CE).

2 thoughts on “Use Alfresco folder rules to perform admin tasks

  1. Pingback: WebDAV, Cyberduck – upload bulk files into Alfresco | Geology FOSS Blog

  2. Pingback: Using javascript console to create a folder rule script in Alfresco | Geology FOSS Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s