I'm converting doc
files to txt
using catdoc
on Linux. To keep the same file name as output file I'm replacing the .doc
extension with .txt
using parameter expension. But there are many doc files ending on .DOC
. How to make the .doc
in ${filename%.doc}.txt
case insentive while keeping the capitals in the filename itself? I can't use ${filename%.*}.txt
because some files have dots in the filename
My current code:
find "${COMPANYPATH}" -iname '*.doc' | while read -r file; do
echo "${file}"
filename=$(basename "${file}")
path="${file%/*}/"
mkdir -p "${OUTPUTPATH}/DOC/${path#$COMPANYPATH/}"
catdoc "${file}" >> "${OUTPUTPATH}/DOC/${path#$COMPANYPATH}${filename%.doc}.txt"
done
input
/home/user/test/2218-0/test.doc
/home/user/test/2218-0/Test2.DOC
Expected output
/home/user/output/test/DOC/2218-0/test.txt
/home/user/output/test/DOC/2218-0/Test2.txt
There are no duplicated files.
find
will only output values with 3-letter suffixes,${filename%.???}
– dave_thompson_085 Mar 31 '24 at 01:50