Thursday, July 26, 2012

Bash for-loop renaming special characters from a list of files

This shows how AWESOME bash is

i=1; for f in ./*.doc; do printf -v num %05d $((i++)); mv "$f" $num.doc; done

A for-loop that iterates all files ending with .doc in the current dir. It uses the printf command to generate a five-digit, zero-padded, incrementing number, then uses the mv command to rename from old name to XXXXX.doc, where XXXXX is the 5-digit number.


Wednesday, July 25, 2012

Alfresco Bulk Filesystem Import Tool

get the tool
http://code.google.com/p/alfresco-bulk-filesystem-import/downloads/list

use the alfresco module managing tool
http://wiki.alfresco.com/wiki/Module_Management_Tool


Installation Steps

The following steps describe how to download and install the Alfresco Bulk Filesystem Import Tool:
  1. Download the latest AMP file containing the tool from here
  2. Shutdown your Alfresco instance (use the .sh inside your alfreso install folder)
  3. Make a backup of the original alfresco.war file. On Tomcat, this is located in ${ALFRESCO_HOME}/tomcat/webapps
  4. Use the Alfresco Module Management Tool to install the AMP file obtained in step 1
  5. Restart Alfresco, watching the log carefully for errors

Running the MMT

Run the following command:
  java -jar alfresco-mmt-2.1.jar [args]
It is compatible with V2.0 WAR files and above.

MMT Commands

The MMT has a number of commands. Details of these are outlined below:
install
usage: install <AMPFileLocation> <WARFileLocation> [options]

valid options:

   -verbose   : enable verbose output
   -directory : indicates that the amp file location specified is a directory.
                All amp files found in the directory and its sub directories are installed.
   -force     : forces installation of AMP regardless of currently installed module version
   -preview   : previews installation of AMP without modifying WAR file
   -nobackup  : indicates that no backup should be made of the WAR

Stop Alfresco

:~/alfresco-4.0.d-1$ ./ctlscript.sh stop
/home/ardian/alfresco-4.0.d-1/apache-tomcat/scripts/ctl.sh : tomcat not running
/home/ardian/alfresco-4.0.d-1/mysql/scripts/ctl.sh : mysql stopped

Check if alfresco is running


ardian@arbk-share:~/alfresco-4.0.d-1$ ps -ef | grep alfresco
ardian   18815 18168  0 11:06 pts/2    00:00:00 grep --color=auto alfresco

locate where the alfresco-mmt-2.1.jar is usually its under alfresco install dir in the bin/ 
For me its /alfresco-4.0.d-1/apps/alfresco

java -jar alfresco-mmt.jar install ~/alfresco-bulk-filesystem-import-1.1-ALF40.amp ~/alfresco-4.0.d-1/apache-tomcat/webapps/alfresco.war

list the modules

java -jar alfresco-mmt.jar list ~/alfresco-4.0.d-1/apache-tomcat/webapps/alfresco.war
Module 'org.alfresco.extension.alfresco-bulk-filesystem-import' installed in '/home/ardian/alfresco-4.0.d-1/apache-tomcat/webapps/alfresco.war'
   -    Title:        Alfresco Bulk Filesystem Import v1.1 (for Alfresco v4.0)
   -    Version:      1.1
   -    Install Date: Wed Jul 25 11:18:19 CEST 2012
   -    Description:   Alfresco Bulk Filesystem Import tool.  Provides high performance bulk loading of content from the server's filesystem into Alfresco.

If you run Alfresco on Linux turn of CIFS: add this
CODE: SELECT ALL
cifs.enabled=false

to alfresco-global.properties.

export BULK=alfresco-bulk-filesystem-import-1.0.amp

java -jar $ALFRESCO_HOME/bin/alfresco-mmt.jar install $ALFRESCO_HOME/amps/$BULK $ALFRESCO_HOME/tomcat/webapps/alfresco.war -force -verbose

$ apply_amps.sh


visit