Made easier to understand
This commit is contained in:
1 parent
3f28e1d023
commit
2afc7b8fe9
1 file changed
+15
-13
+15
-13
@@ -1,36 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
#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 :
|
||||
do
|
||||
echo -e "What is the directory with the pdfs?"
|
||||
echo "Where is the directory with ALL the pdf statments?"
|
||||
read PDFDIR
|
||||
#PDFDIR="/home/btmccrea/Downloads/pdfs"
|
||||
if [ -d $PDFDIR ]
|
||||
then
|
||||
break
|
||||
else
|
||||
echo -e "Directory not found."
|
||||
echo "Directory not found."
|
||||
fi
|
||||
done
|
||||
#Get the folder for the output file.
|
||||
echo ""
|
||||
while :
|
||||
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
|
||||
#OUTPUTFOLDER="/home/btmccrea/Downloads/output"
|
||||
if [ -d $OUTPUTFOLDER ]
|
||||
then
|
||||
break
|
||||
else
|
||||
echo -e "Directory not found."
|
||||
echo "Directory not found."
|
||||
fi
|
||||
done
|
||||
|
||||
#Create the csv and headers for the Addresses. It is tab separated.
|
||||
mkdir $OUTPUTFOLDER/Non_Blank
|
||||
touch $OUTPUTFOLDER/Non_Blank/Addresses.csv
|
||||
echo -e "File,User,Street,City,State,Zip" > $OUTPUTFOLDER/Non_Blank/Addresses.csv
|
||||
mkdir $OUTPUTFOLDER/Addresses
|
||||
touch $OUTPUTFOLDER/Addresses/Addresses.csv
|
||||
echo -e "File,User,Street,City,State,Zip" > $OUTPUTFOLDER/Addresses/Addresses.csv
|
||||
|
||||
#Create csv with all the files with missing addresses
|
||||
mkdir $OUTPUTFOLDER/Missing_Addresses
|
||||
@@ -56,7 +58,7 @@ do
|
||||
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"
|
||||
echo "Copying file to the folder called 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
|
||||
@@ -68,9 +70,9 @@ do
|
||||
STATE=$(echo $ADDRESS2 | cut -d" " -f1)
|
||||
ZIP=$(echo $ADDRESS2 | cut -d" " -f2)
|
||||
|
||||
echo -e "$f,$USER,$ADDRESS1,$CITY,$STATE,$ZIP" >> $OUTPUTFOLDER/Non_Blank/Addresses.csv
|
||||
cp "$f" $OUTPUTFOLDER/Non_Blank/
|
||||
echo -e "Copying file to Non_Blank"
|
||||
echo -e "$f,$USER,$ADDRESS1,$CITY,$STATE,$ZIP" >> $OUTPUTFOLDER/Addresses/Addresses.csv
|
||||
cp "$f" $OUTPUTFOLDER/Addresses/
|
||||
echo "Copying file to the folder called Addresses"
|
||||
fi
|
||||
done
|
||||
exit
|
||||
Reference in new issue
Block a user