#!/bin/bash html="{include-lightbox} \n" IFS=$(echo -en "\n\b") Database="Confluence" # Arguments Dir=$1 Id=$2 MakeToc=$3 # Check Arguments if [ $# -ne 3 ] then echo "There are not 3 Arguments: Dir ArticleId yes/no" exit 0 fi if [ Dir == "" ] then echo "Argument 1 is empty" exit 0 fi if [ ! -d /data/images/$Dir ] then echo "Argument 1 Dir: $Dir does not exist" exit 0 fi cd /data/images/"$Dir" for file in `find . -type d | grep -v "thumbs" | grep -v "cache" | sort` do NumOfPics=`ls -t "$file" | egrep -i "\.(jpg|gif|png|bmp)$" | wc -l` if [ $NumOfPics -gt 0 ] then file=$(echo "$file"|sed 's/\.\///g') html="$html h1. $file \n" group=$file for image in `ls "$file" | egrep -i "\.(jpg|gif|png|bmp)$"` #for image in `find "$file" -depth 1 -type f | egrep -i "\.(jpg|gif|png|bmp)$" ` do file2=$(echo "$file"|sed 's/ /%20/g') html="$html {me-image:path=$Dir/$file2/|image=$image|group=$group}" done html=="$html \n" fi for movie in `find "$file"/ -maxdepth 1 -type f | grep -v thumbs | egrep -i "\.(bobsos|flv)$" | sort` do html="$html {me-video:/images/$Dir/$movie}" done done if [ $MakeToc == "no" ] then sql="UPDATE BODYCONTENT set body='$html' where contentid=$Id" else sql="UPDATE BODYCONTENT set body='{toc} \n $html' where contentid=$Id" fi echo "SET NAMES 'utf8';$sql" > /tmp/insert.sql mysql --user=cadmin --password=******* confluence < /tmp/insert.sql rm /tmp/insert.sql