Create Folders and Sub-folders on Uploading a CSV File in Alfresco

A typical Document Management System use case in Alfresco would require creating multiple folders while implementing for the first time or any time in future as well. Those folders can be for each employee, branch or project in the organization. Creating them manually is a mundane, time-consuming and prone-to-error task. How if you can create these folders with a mere upload of a CSV file? Sounds interesting?

In this blog, we have provided you a code using which Alfresco developers would be able to set a mechanism for the users who would get the following functionality.

We need to have two folders, one in which we would upload the CSV and the other where the folders will be residing after auto-generation, let’s name it as target folder. We have considered that the auto-generated folder will be renamed as columnAvalue_comunBvalue (by using values in the adjoining columns in the same row of CSV). So, the CSV we upload in this case should have one row for each folder with two columns to be placed as folder names. The sub-folders will be fixed for any auto-generated folder (In this case we have named them child1…child6). You may amend the code as per the business requirements of your client.

Here are the steps to follow:

Step 1: For creating folders and sub-folders we need to write the script.

So first we create "csvUploadFolderCreation.js" file and put it in "Data Dictionary/Scripts"
 var siteName = document.getSiteShortName();

var path = companyhome.childByNamePath("Sites/"+siteName+"/documentLibrary/Target");

var subFolders = ["child1","child2","child3","child4","child5","child6"];

var col1=null,col2=null;


var fileContent = document.getContent();

var csvline = fileContent.split("\n");

var csvLineLength = csvline.length;

for (var i=1 ; i
Step 2: Create a folder (Csv Upload) in your site and go to the action "Manage Rules". Now create a new rule. Add other info wise requirment and goto to "Perform Action", select execute script and select our custom script.   Step 3: Create folder "Target" Which Contains all the folders which are created from csv.   Step 4: Now upload the csv file in "CSV Upload" folder. Sub-folder will be created in Target folder as per the csv data.   #CTA-2#
Alfresco Development


Alfresco Development: How It Helps Businesses and Why It's Beneficial

Learn about Alfresco development and its benefits for businesses. Discover how leveraging Alfresco can enhance efficiency and collaboration.

Alfresco ECM Consultants


Alfresco ECM Consultants Unveil Secrets to Success

Mastering Alfresco Development: Essential Tips for Success in ECM Solutions" provides crucial insights and strategies for developers to excel in creating robust ECM solutions using the Alfresco platform. With essential tips and best practices, this resource is indispensable for both novice and experienced developers seeking to harness Alfresco's full potential for ECM projects.

Transform Your Business With Digital Enterprise Solutions

Contact us

Our Offices


401, One World West, Nr. Ambli T-Junction 200, S P Ring Road, Bopal, Ahmedabad, Gujarat 380058


Kemp House 160 City Road, London, United Kingdom EC1V 2NX


Nürnberger Str. 46 90579 Langenzenn Deutschland


Level 36 Riparian Plaza, 71 Eagle Street, Brisbane, QLD 4000


4411 Suwanee Dam road, Bld. 300 Ste. 350 Suwanee GA, 30024


Cube Work Space, 24 Hans Strijdom Avenue, Cape Town


B 503 Sama Tower, Sheikh Zayed Road, United Arab Emirates

country-flag CANADA

34 Applegrove Ct. Brampton ON L6R 2Y8