Files
eoy-pdf-sortandmerge/Find_Missing_Addresses.sh
T

45 lines
965 B
Bash
Executable File

#!/bin/bash
while :
do
echo -e "What is the directory with the pdfs?"
#read PDFDIR
PDFDIR=/home/btmccrea/Downloads/pdfs/
if [ -d $PDFDIR ]; then
break
else
echo -e "Directory not found."
fi
done
while :
do
echo -e "What is the output directory for the pdf's with missing addresses?"
#read OUTPUTFOLDER
OUTPUTFOLDER=/home/btmccrea/Documents/output/
if [ -d $PDFDIR ]; then
break
else
echo -e "Directory not found."
fi
done
touch "$OUTPUTFOLDER"Addresses.csv
echo "File, User, Address" > "$OUTPUTFOLDER"Addresses.csv
#FILES=$(ls $PDFDIR)
cd $PDFDIR
#echo $FILES
#* represensts All files in the current directory
for f in *.pdf ;
do
pdftotext "$f" temp
USER=$(sed -n '13p' temp)
ADDRESS1=$(sed -n '14p' temp)
ADDRESS2=$(sed -n '15p' temp)
echo "$f, $USER, '$ADDRESS1 $ADDRESS2'" >> "$OUTPUTFOLDER"Addresses.csv
done
exit