Hi Team,
I need some help regarding my following query.
Problem Statement:
Currently around 1500 files are wrongly placed in 255 folders with some misleading value of the metadata attributes as well.
Target State:
Relocate these 1500 files FROM their existing 255 folders TO 255 NEWLY CREATED folders and update the value of some of the medatadata attributes as well.
Query
Is there any programatic way to achieve this target state by using Alfresco out of the box tools or programing interface?
Possible Options
Please dont hesitate to ask in case you need any further detail. Thanks.
Is this a one-time deal or something that you will be doing more than that? If you have access to the Share interface, you can write JSON to do this and then associate a rule with the parent folder of the original 255 folders and then run the rule to create the folders and move the files into them. Not sure if this would work, but it can be done.
Thank you for your help, it is really appriciated.
Yes, this is one-time deal.
Can we alter the meta deta attribute values of the moving file as well with this technique?
If you dont mind can you please write a sample JSON rule which is going to meet my requirment?
In case there is any helpful article which descrites how to write JSON rule then please share it.
Hello,
Using out of the box tools you could create a JavaScript and executing it via a rule in the parent of the existing folders. Here are a very simple approach:
// this is the root of the target var targetRoot = companyhome.childByNamePath("Venzia"); function getTargetName(name) { // Here you have to add the logic to found the name of the correct space. return 'Target ' + name; } function getTargetSpace(name) { var targetSpaceName = getTargetName(name); var newSpace = targetRoot.childByNamePath(targetSpaceName); if(newSpace === null) { newSpace = targetRoot.createFolder(targetSpaceName); } newSpace.properties.title = 'Creado'; newSpace.save(); return newSpace; } // document is the node in wich the rule is executing var currentSpace = document; var targetSpace = getTargetSpace(document.properties["cm:name"]); var files = currentSpace.getChildren(); for(var i in files){ var newFile = files[i].copy(targetSpace); logger.log(newFile.properties["cm:name"]); newFile.properties.title = 'Copiado'; newFile.save(); }
Save this code in a file script.js and upload it in the Alfresco space:
Company Home > Dictionary > Scripts.
Follow this instructions to create a rule in the parent of the old folders:
https://docs.alfresco.com/5.2/tasks/library-folder-rules-define-create.html.
Once you have the rule execute it from Manage Rules page.
Of course here we are doing some assumptions:
Regards
Discussions, help and advice about the Alfresco Development Framework.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.