Made easier to understand

This commit is contained in:
TRBC Developer committed 2024-01-18 20:25:48 +00:00
1 parent 3f28e1d023
commit 2afc7b8fe9
1 file changed
+15 -13
+15 -13
View File
@@ -1,36 +1,38 @@
#!/bin/bash #!/bin/bash
#Get the folder with the pdf documents in it. #Get the folder with the pdf documents in it.
echo ""
echo "This will sort out the addresses in all the Statement PDF's into 2 folders so that you can then run the Merge file."
echo "To get started please answer 2 questions."
while : while :
do do
echo -e "What is the directory with the pdfs?" echo "Where is the directory with ALL the pdf statments?"
read PDFDIR read PDFDIR
#PDFDIR="/home/btmccrea/Downloads/pdfs"
if [ -d $PDFDIR ] if [ -d $PDFDIR ]
then then
break break
else else
echo -e "Directory not found." echo "Directory not found."
fi fi
done done
#Get the folder for the output file. #Get the folder for the output file.
echo ""
while : while :
do do
echo -e "What is the output directory for the pdf's with missing addresses?" echo "What output directory do you want for the sorted pdf's? This will sort into 2 folders, Missing_Addresses and Address"
read OUTPUTFOLDER read OUTPUTFOLDER
#OUTPUTFOLDER="/home/btmccrea/Downloads/output"
if [ -d $OUTPUTFOLDER ] if [ -d $OUTPUTFOLDER ]
then then
break break
else else
echo -e "Directory not found." echo "Directory not found."
fi fi
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.
mkdir $OUTPUTFOLDER/Non_Blank mkdir $OUTPUTFOLDER/Addresses
touch $OUTPUTFOLDER/Non_Blank/Addresses.csv touch $OUTPUTFOLDER/Addresses/Addresses.csv
echo -e "File,User,Street,City,State,Zip" > $OUTPUTFOLDER/Non_Blank/Addresses.csv echo -e "File,User,Street,City,State,Zip" > $OUTPUTFOLDER/Addresses/Addresses.csv
#Create csv with all the files with missing addresses #Create csv with all the files with missing addresses
mkdir $OUTPUTFOLDER/Missing_Addresses mkdir $OUTPUTFOLDER/Missing_Addresses
@@ -56,7 +58,7 @@ do
if [ -z "$ADDRESS1" ] if [ -z "$ADDRESS1" ]
then then
#Move the file with the Missing addresses to the Missing Address folder and make an note in its csv. #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" echo "Copying file to the folder called Missing_Addresses"
cp "$f" "$OUTPUTFOLDER"/Missing_Addresses/ cp "$f" "$OUTPUTFOLDER"/Missing_Addresses/
echo -e "$f\t$USER" >> "$OUTPUTFOLDER"/Missing_Addresses/Missing_Addresses.csv 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
@@ -68,9 +70,9 @@ do
STATE=$(echo $ADDRESS2 | cut -d" " -f1) STATE=$(echo $ADDRESS2 | cut -d" " -f1)
ZIP=$(echo $ADDRESS2 | cut -d" " -f2) ZIP=$(echo $ADDRESS2 | cut -d" " -f2)
echo -e "$f,$USER,$ADDRESS1,$CITY,$STATE,$ZIP" >> $OUTPUTFOLDER/Non_Blank/Addresses.csv echo -e "$f,$USER,$ADDRESS1,$CITY,$STATE,$ZIP" >> $OUTPUTFOLDER/Addresses/Addresses.csv
cp "$f" $OUTPUTFOLDER/Non_Blank/ cp "$f" $OUTPUTFOLDER/Addresses/
echo -e "Copying file to Non_Blank" echo "Copying file to the folder called Addresses"
fi fi
done done
exit exit