I have over a thousand files in a directory which I want to convert to text files. I use a code like the one below to first take out the spaces in the file names and then convert the files to text:
!/bin/bash
find . -name '*.pdf' | while read file;
do
target=`echo "$file" | sed 's/ /_/g'`;
echo "Renaming '$file' to '$target'";
mv "$file" "$target";
chmod 777 *.pdf;
pdftotext -layout "$target" "$target.txt";
done;
This code however converts a file like I love you.pdf to I_love_you.pdf.txt. I want to remove the .pdf part of the final file extension.