Finished Find Addresses. Starte Remove and Sort scripts

This commit is contained in:
btmccrea committed 2020-12-23 16:26:31 -05:00
1 parent b5f85b754f
commit 2fb552ed8a
3 files changed
+59 -8

No files matched your search

+13 -8
View File
@@ -1,22 +1,23 @@
#!/bin/bash
#Get the folder with the pdf documents in it.
while :
do
echo -e "What is the directory with the pdfs?"
#read PDFDIR
PDFDIR=/home/btmccrea/Downloads/pdfs/
read PDFDIR
#PDFDIR=/home/btmccrea/Downloads/pdfs/
if [ -d $PDFDIR ]; then
break
else
echo -e "Directory not found."
fi
done
#Get the folder for the output file.
while :
do
echo -e "What is the output directory for the pdf's with missing addresses?"
#read OUTPUTFOLDER
OUTPUTFOLDER=/home/btmccrea/Documents/output/
read OUTPUTFOLDER
#OUTPUTFOLDER=/home/btmccrea/Documents/output/
if [ -d $PDFDIR ]; then
break
else
@@ -24,19 +25,23 @@ do
fi
done
#Create the csv and headers for the Addresses. It is tab separated.
touch "$OUTPUTFOLDER"Addresses.csv
echo "File, User, Address" > "$OUTPUTFOLDER"Addresses.csv
echo -e "File\tUser\tAddress" > "$OUTPUTFOLDER"Addresses.csv
#FILES=$(ls $PDFDIR)
cd $PDFDIR
#echo $FILES
#* represensts All files in the current directory
#*.pdf represensts All files in the current directory with a pdf extention.
for f in *.pdf ;
do
#pdftotext converst the file to text and places it in the file name temp
pdftotext "$f" temp
#assigns the lines with relevant values to their variable
USER=$(sed -n '13p' temp)
ADDRESS1=$(sed -n '14p' temp)
ADDRESS2=$(sed -n '15p' temp)
echo "$f, $USER, '$ADDRESS1 $ADDRESS2'" >> "$OUTPUTFOLDER"Addresses.csv
#Adds the row of variables to the csv. >> appends to the file. \t represents tabs
echo -e "$f\t$USER\t$ADDRESS1 $ADDRESS2" >> "$OUTPUTFOLDER"Addresses.csv
done
exit