55 lines
1.4 KiB
Bash
55 lines
1.4 KiB
Bash
|
|
#!/bin/sh
|
||
|
|
#
|
||
|
|
# Migrate CL provided folders and optionally screwed up ptx directories to correct scheme
|
||
|
|
#
|
||
|
|
# Usage: migrate-all.sh <src-root> <dest-root> [<ptx-root>]
|
||
|
|
|
||
|
|
SRCDIR=$1
|
||
|
|
DSTDIR=$2
|
||
|
|
PTXDIR=$3
|
||
|
|
|
||
|
|
if [ ! -d "$SRCDIR" -o ! -d "$DSTDIR" ]; then
|
||
|
|
echo "Usage: migrate-all.sh srcdir destdir [ptxdir]"
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
mkdir -p "${DSTDIR}"
|
||
|
|
if [ ! -d "${DSTDIR}" ]; then
|
||
|
|
echo "Unable to create directory: ${DSTDIR}"
|
||
|
|
exit 2
|
||
|
|
fi
|
||
|
|
|
||
|
|
echo "Finding directories to process..."
|
||
|
|
find "$SRCDIR" -mindepth 1 -maxdepth 1 -type d | while read dir; do
|
||
|
|
dst=${DSTDIR}`echo $dir | sed "s#$SRCDIR##"`
|
||
|
|
echo "*** Make ${dst} isDataDirectory ***"
|
||
|
|
mkdir -p ${dst}
|
||
|
|
touch ${dst}/isDataDirectory
|
||
|
|
|
||
|
|
dstimages=${dst}/output/FRCapture/images
|
||
|
|
dstocr=${dst}/output/OCR
|
||
|
|
mkdir -p "${dstimages}"
|
||
|
|
echo "*** Processing directory: $dir to $dstimages ***"
|
||
|
|
#find $dir -name '*.pdf' | while read pdf; do
|
||
|
|
# echo "cp ${pdf} ${dstimages}"
|
||
|
|
# cp ${pdf} ${dstimages}
|
||
|
|
#done
|
||
|
|
#cp --verbose ${dir}/* ${dstimages}
|
||
|
|
find ${dir} -name '*.pdf' -print0 -exec cp -v {} ${dstimages} \;
|
||
|
|
|
||
|
|
if [ "$PTXDIR" != "" ]; then
|
||
|
|
srcptx=${PTXDIR}`echo $dir | sed "s#$SRCDIR##"`
|
||
|
|
echo "*** Processing PTX: $srcptx to $dstocr ***"
|
||
|
|
mkdir -p ${dstocr}
|
||
|
|
# this assumes same fs for screwup
|
||
|
|
#find $srcptx -name '*.ptx' | while read ptx; do
|
||
|
|
# echo "mv ${ptx} ${dstocr}"
|
||
|
|
# mv ${ptx} ${dstocr}
|
||
|
|
#done
|
||
|
|
mv --verbose ${srcptx}/*.ptx* ${dstocr}
|
||
|
|
fi
|
||
|
|
|
||
|
|
done
|
||
|
|
|
||
|
|
exit 0
|