Quantcast
Channel: Alfresco Forums - Alfresco Share
Viewing all articles
Browse latest Browse all 877

Solution: tag multiple files at once

$
0
0

Hi all,

I've developed a very simple process for tagging multiple files at once. It relies on repository actions/rules and a couple lines of JavaScript, and it's all described below. Once you're all set up, you will be able to make a file inherit tags from a folder you move it into. My example is used for an Image Gallery, so my rule also moves files out of the tagged folders and back into the Image Gallery Document Library.

I am running Alfresco Community Edition v3.3 on my local machine and I am using the Alfresco Share interface.

-------------------------------------------

First, we need to create a JavaScript file with a couple lines of code in it. This is easy, even for people who know nothing about JavaScript. How is it easy, you ask? It's easy because I'm going to tell you exactly what you need to do!

Open Notepad and copy the following code into your blank text file:

//Alfresco auto-tagger
//compliments of Zach Bennett, Eagle Productivity Solutions
//two lines of code
//free for anyone to use
//no license, no strings attached
 
//get tags from parent (folder) node
var tagArray = document.parent.getTags();
 
//add the tags to the document node
document.addTags(tagArray);

Now go to File -> Save As... Name your file "tagger.js" and save it to your desktop (or wherever you feel is appropriate). That's all there is to creating the JavaScript file, now we just need to upload it to Alfresco.

Go to your Repository

Dive into the Data Dictionary

And then into Scripts

Then just select Upload and browse to tagger.js (that JavaScript file you created)

Now your script is ready to use! All that is left do is create a couple folders and a rule.

In this example, I created a folder called "auto-tagger" in my Image Gallery's Document Library. I then created a rule that runs the JavaScript code I wrote. My intention was to put temporary folders inside the auto-tagger folder, each with a set of tags that I could reuse over and over.

On the auto-tagger folder, select Manage Rules

Click Create Rules

Give the rule a name, and make sure the check the 'Rule applies to subfolders' check box

*** Very important edit ***

You need to set the criteria so this rule only applies to Content items and NOT Folders (unless you want to make the same mistake I made!)

Under Perform Action, select Execute script

And in the drop-down box that appears, you can now select tagger.js, which is the JavaScript file we created earlier

To make sure this folder stays empty (which was important for my purpose of an Image Gallery), we will add another action to the rule.

Click the plus symbol (+) to the right side of this rule

For this action, select Move

Then select where you want files to be moved to. I wanted files to be moved to the main Document Library of my Image Gallery site, but you may want to do things differently

And finally, click Create

Now that the rule is created (and applied to subfolders of auto-tagger), you can create folders inside of the auto-tagger folder and add tags to them. Once you do that, can can move files into (or upload directly to) those subfolders to make them inherit the appropriate tags. Any files created in or added to those subfolders will automatically be moved to the location you selected above (like my Image Gallery Document Library).

I hope this helps - happy tagging!


Viewing all articles
Browse latest Browse all 877

Trending Articles