Fixed problems with 2020 file and logic improvments

This commit is contained in:
btmccrea committed 2021-01-24 08:36:11 -05:00
1 parent 2fb552ed8a
commit 628cffcbda
3 files changed
+109 -36

No files matched your search

+40 -19
View File
@@ -4,9 +4,10 @@
while : while :
do do
echo -e "What is the directory with the pdfs?" echo -e "What is the directory with the pdfs?"
read PDFDIR #read PDFDIR
#PDFDIR=/home/btmccrea/Downloads/pdfs/ PDFDIR="/home/btmccrea/Downloads/pdfs"
if [ -d $PDFDIR ]; then if [ -d $PDFDIR ]
then
break break
else else
echo -e "Directory not found." echo -e "Directory not found."
@@ -16,9 +17,10 @@ done
while : while :
do do
echo -e "What is the output directory for the pdf's with missing addresses?" echo -e "What is the output directory for the pdf's with missing addresses?"
read OUTPUTFOLDER #read OUTPUTFOLDER
#OUTPUTFOLDER=/home/btmccrea/Documents/output/ OUTPUTFOLDER="/home/btmccrea/Downloads/output"
if [ -d $PDFDIR ]; then if [ -d $OUTPUTFOLDER ]
then
break break
else else
echo -e "Directory not found." echo -e "Directory not found."
@@ -26,24 +28,43 @@ do
done done
#Create the csv and headers for the Addresses. It is tab separated. #Create the csv and headers for the Addresses. It is tab separated.
touch "$OUTPUTFOLDER"Addresses.csv mkdir $OUTPUTFOLDER/Non_Blank
echo -e "File\tUser\tAddress" > "$OUTPUTFOLDER"Addresses.csv touch $OUTPUTFOLDER/Non_Blank/Addresses.csv
#FILES=$(ls $PDFDIR) echo -e "File\tUser\tAddress" > $OUTPUTFOLDER/Non_Blank/kkAddresses.csv
#Create csv with all the files with missing addresses
mkdir $OUTPUTFOLDER/Missing_Addresses
touch $OUTPUTFOLDER/Missing_Addresses/Missing_Addresses.csv
echo -e "File\tUser" > $OUTPUTFOLDER/Missing_Addresses/Missing_Addresses.csv
cd $PDFDIR cd $PDFDIR
#echo $FILES #FOLDER=$(ls | grep *.pdf)
echo $FOLDER
#*.pdf represensts All files in the current directory with a pdf extention. #*.pdf represensts All files in the current directory with a pdf extention.
for f in *.pdf ; for f in $PDFDIR/*
do do
echo "Processing file $f."
#pdftotext converst the file to text and places it in the file name temp #pdftotext converst the file to text and places it in the file name temp
pdftotext "$f" temp pdftotext "$f" - > TEMP
#cat TEMP
#assigns the lines with relevant values to their variable #assigns the lines with relevant values to their variable
USER=$(sed -n '13p' temp) USER=$(sed -n '10p' TEMP)
ADDRESS1=$(sed -n '14p' temp) ADDRESS1=$(sed -n '11p' TEMP)
ADDRESS2=$(sed -n '15p' temp) ADDRESS2=$(sed -n '12p' TEMP)
echo -e "User is $USER"
echo -e "Address is $ADDRESS1 $ADDRESS2"
if [ -z "$ADDRESS1" ]
then
#Move the file with the Missing addresses to the Missing Address folder and make an note in its csv.
echo -e "Copying file to Missing_Addresses"
cp "$f" "$OUTPUTFOLDER"/Missing_Addresses/
echo -e "$f\t$USER" >> "$OUTPUTFOLDER"/Missing_Addresses/Missing_Addresses.csv
#Adds the row of variables to the csv. >> appends to the file. \t represents tabs #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 else
echo -e "$f\t$USER\t$ADDRESS1 $ADDRESS2" >> $OUTPUTFOLDER/Non_Blank/Addresses.csv
cp "$f" $OUTPUTFOLDER/Non_Blank/
echo -e "Copying file to Non_Blank"
fi
done done
exit exit
Regular → Executable
+57 -8
View File
@@ -1,19 +1,68 @@
#!/bin/bash #!/bin/bash
#import list from csv
echo "Please clear all feilds except for the file name feild from the csv."
while IFS='\t' read (awk -F, 'NR > 1' { print $1})
#cd to and then remove files
#Get the folder with the pdf documents in it. #Get the folder with the pdf documents in it.
while : while :
do do
echo -e "What is the directory with the pdfs?" echo -e "What is the directory with the pdfs?"
read PDFDIR #read PDFDIR
#PDFDIR=/home/btmccrea/Downloads/pdfs/ PDFDIR="/home/btmccrea/Downloads/pdfs"
if [ -d $PDFDIR ]; then if [ -d $PDFDIR ]
then
break break
else else
echo -e "Directory not found." echo -e "Directory not found."
fi fi
done 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/Downloads/output/Final"
if [ -d $OUTPUTFOLDER ]
then
break
else
echo -e "Directory not found."
fi
done
#Get the folder with the csv
while :
do
echo -e "What path and file with?"
#read CSVFILE
if [ -f $CSVFILE ]
then
break
else
echo -e "File not found."
fi
done
#import list from csv
echo "Processing csv."
while IFS=$'\t' read -r FILE
do
echo "FILE $FILE"
# echo "user $USER"
# echo "match $MATCH"
# echo "${array[0]}"
# if [[ "$MATCH" == "Match-Mailable" ]]
# then
#
# echo -e "Processing file $FILE"lY
cp $PDFDIR/"$FILE" $OUTPUTFOLDER
# else
# echo "no match"
# fi
done < /home/btmccrea/Downloads/Smarty_Streets.csv
#FILE=$(cat /home/btmccrea/Downloads/Smarty_Streets.csv)
#echo $FILE
#IFS=$'\t'
#for f in Smarty_Streets.csv
#do
# echo "doing file $f"
# cp $PDFDIR/"$f" $OUTPUTFOLDER
#done
#cd to and then remove files
+12 -9
View File
@@ -5,23 +5,26 @@
#Get the location of the PDF files #Get the location of the PDF files
echo "What is the location of the PDF files" echo "What is the location of the PDF files"
read FILE #read FILE
FILE=/home/btmccrea/Downloads/output/Only_Good/*
#cd $FILE
for FILENAME in $FILE for FILENAME in $FILE
do do
echo $FILENAME
#The next Line assigns the number of pages to the value LOCATION to be used for were the file goes #The next Line assigns the number of pages to the value LOCATION to be used for were the file goes
LOCATION=$(pdfinfo "$FILENAME" | grep Pages: | awk '{print $2}') LOCATION=$(pdfinfo "$FILENAME" | grep Pages: | awk '{print $2}')
#Test if the file exists and if it does move it to Temp.pdf to be merged back to its original location. #Test if the file exists and if it does move it to Temp.pdf to be merged back to its original location.
if test -f /mnt/tmpfs/Statement-Pages-$LOCATION.pdf; then if test -f /home/btmccrea/Downloads/output/Final/Statement-Pages-$LOCATION.pdf
mv /mnt/tmpfs/Statement-Pages-$LOCATION.pdf /mnt/tmpfs/temp.pdf then
mv /home/btmccrea/Downloads/output/Final/Statement-Pages-$LOCATION.pdf /home/btmccrea/Downloads/output/Final/temp.pdf
pdfunite "$FILENAME" /home/btmccrea/Downloads/output/Final/temp.pdf /home/btmccrea/Downloads/output/Final/Statement-Pages-$LOCATION.pdf
else else
pdfunite "$FILENAME" /mnt/tmpfs/temp.pdf /mnt/tmpfs/Statement-Pages-$LOCATION.pdf
#IF the file doesn't exist create the file with the merge. #IF the file doesn't exist create the file with the merge.
pdfunite "$FILENAME" /mnt/tmpfs/Statement-Pages-$LOCATION.pdf pdfunite "$FILENAME" /home/btmccrea/Downloads/output/Final/Statement-Pages-$LOCATION.pdf
fi; fi
#once everything else is doen Make the directory to place the files into #once everything else is doen Make the directory to place the files into
#and copy the finished files into it. #and copy the finished files into it.
mkdir $FILE/Finished/ #mkdir $FILE/Finished/
cp -r /mnt/tmpfs/Statement-* $FILE/Finished/ #cp -r /home/btmccrea/Downloads/output/Final/Statement-* $FILE/Finished/
done done
exit exit