#!/bin/sh


writeHeader(){
    echo "ClipID,ClipMD5,ClipByteSize,RelativeClipPath,URL,URL_Type,URL_MD5,URL_ByteSize,user,password"
}




setName=$1
### This points to the same location, one on www space, one on the file system
urlRoot=$2
urlUser="$3"
urlPW="$4"
fsRoot=$5
md5Prog=$6

writeFileRecord(){
    filename=$1
    clipid=`basename $filename`
    relPath=`dirname $filename|sed "s:^$setName/::" | sed "s:^$setName$:.:"`
    size=`ls -l $fsRoot/$filename | awk '{print $5}'`
    md5=`cat $fsRoot/$filename | $md5Prog | awk '{print $1}'`
    echo $clipid,$md5,$size,$relPath,$urlRoot/$filename,file,$md5,$size,$urlUser,"$urlPW"  #===== $fsRoot $setName $filename
}

writeHeader
for f in `(cd $fsRoot; find $setName -type f)` ; do
    writeFileRecord $f 
done





