Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc361b4127 | ||
|
|
a7113367e7 | ||
|
|
03b5b5d7df | ||
|
|
ae55276298 | ||
|
|
59e0b7c489 | ||
|
|
8346d2e3ea | ||
|
|
fc89b0662d | ||
|
|
3cf3404f73 | ||
|
|
9df136d24a | ||
|
|
6930351401 | ||
|
|
053b3ef75f | ||
|
|
e89085043b | ||
|
|
78462e55a9 | ||
|
|
2afc7b8fe9 | ||
|
|
3f28e1d023 | ||
|
|
f02850cd2a | ||
|
|
612943e9f8 | ||
|
|
c89f61366c | ||
|
|
628cffcbda | ||
|
|
2fb552ed8a | ||
|
|
b5f85b754f | ||
|
|
5252fc1932 |
No files matched your search
Executable
+82
@@ -0,0 +1,82 @@
|
|||||||
|
#!/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 "Where is the directory with ALL the pdf statments?"
|
||||||
|
# read PDFDIR
|
||||||
|
# if [ -d $PDFDIR ]
|
||||||
|
# then
|
||||||
|
# break
|
||||||
|
# else
|
||||||
|
# echo "Directory not found."
|
||||||
|
# fi
|
||||||
|
#done
|
||||||
|
#Get the folder for the output file.
|
||||||
|
#echo ""
|
||||||
|
#while :
|
||||||
|
#do
|
||||||
|
# echo -e "What output directory do you want for the sorted pdf's? This will sort into 2 folders, Missing_Addresses and Address"
|
||||||
|
# read OUTPUTFOLDER
|
||||||
|
# if [ -d $OUTPUTFOLDER ]
|
||||||
|
# then
|
||||||
|
# break
|
||||||
|
# else
|
||||||
|
# echo "Directory not found."
|
||||||
|
# fi
|
||||||
|
#done
|
||||||
|
|
||||||
|
#Create the csv and headers for the Addresses. It is tab separated.
|
||||||
|
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
|
||||||
|
touch $OUTPUTFOLDER/Missing_Addresses/Missing_Addresses.csv
|
||||||
|
|
||||||
|
echo -e "File\tUser" > $OUTPUTFOLDER/Missing_Addresses/Missing_Addresses.csv
|
||||||
|
|
||||||
|
cd $PDFDIR
|
||||||
|
#FOLDER=$(ls | grep *.pdf)
|
||||||
|
#echo $FOLDER
|
||||||
|
#*.pdf represensts All files in the current directory with a pdf extention.
|
||||||
|
for f in $PDFDIR/*
|
||||||
|
do
|
||||||
|
echo "Processing file $f."
|
||||||
|
#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 '12p' TEMP)
|
||||||
|
ADDRESS1=$(sed -n '13p' TEMP)
|
||||||
|
ADDRESS2=$(sed -n '14p' 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 "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
|
||||||
|
else
|
||||||
|
# Split Addresses
|
||||||
|
CITY=$(echo $ADDRESS2 | cut -d, -f1)
|
||||||
|
ADDRESS2=$(echo $ADDRESS2 | sed -e "s/$CITY, //")
|
||||||
|
|
||||||
|
STATE=$(echo $ADDRESS2 | cut -d" " -f1)
|
||||||
|
ZIP=$(echo $ADDRESS2 | cut -d" " -f2)
|
||||||
|
|
||||||
|
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
|
||||||
|
echo "All Done!" You can find all the Files in $OUTPUTFOLDER!"
|
||||||
|
echo " "
|
||||||
|
echo " "
|
||||||
|
|
||||||
|
exit
|
||||||
@@ -1,3 +1,11 @@
|
|||||||
# EOY PDF Sortandmerge
|
# EOY PDF Sort & Merge
|
||||||
|
|
||||||
|
## Prerequisite
|
||||||
|
1. Linux for Windows Subsystem (WSL2)
|
||||||
|
2. Ubuntu installed from Windows Store
|
||||||
|
|
||||||
|
To start make sure all files are downloaded and in the same directory. Then run the application.
|
||||||
|
|
||||||
|
./Run.sh
|
||||||
|
|
||||||
Project to sort, filter, and merge pdf files.
|
Project to sort, filter, and merge pdf files.
|
||||||
Executable
+68
@@ -0,0 +1,68 @@
|
|||||||
|
#!/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"
|
||||||
|
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/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
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
|
||||||
|
echo "Welcome! It must be the start of a new year! In order to get started with sorting and merging the PDF documents I need to know a little more information."
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
read -p 'Where is the directory that has the PDF statments with address? ' PDFDIR
|
||||||
|
#read PDFDIR
|
||||||
|
#Get the folder for the output file.
|
||||||
|
echo
|
||||||
|
read -p 'What output directory do you want for the sorted PDFs? ' OUTPUTFOLDER
|
||||||
|
#read OUTPUTFOLDER
|
||||||
|
echo
|
||||||
|
echo "The PDFs statments are in $PDFDIR?"
|
||||||
|
echo "The output folder will be $OUTPUTFOLDER."
|
||||||
|
echo
|
||||||
|
read -p "Press Enter to continue" </dev/tty
|
||||||
|
echo
|
||||||
|
|
||||||
|
|
||||||
|
#./Find_Missing_Addresses.sh $PDFDIR $OUTPUTFOLDER
|
||||||
|
|
||||||
|
#Create the csv and headers for the Addresses. It is tab separated.
|
||||||
|
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
|
||||||
|
touch $OUTPUTFOLDER/Missing_Addresses/Missing_Addresses.csv
|
||||||
|
|
||||||
|
echo -e "File\tUser" > $OUTPUTFOLDER/Missing_Addresses/Missing_Addresses.csv
|
||||||
|
|
||||||
|
cd $PDFDIR
|
||||||
|
#FOLDER=$(ls | grep *.pdf)
|
||||||
|
#echo $FOLDER
|
||||||
|
#*.pdf represensts All files in the current directory with a pdf extention.
|
||||||
|
for f in $PDFDIR/*
|
||||||
|
do
|
||||||
|
echo "Processing file $f."
|
||||||
|
#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 '12p' TEMP)
|
||||||
|
ADDRESS1=$(sed -n '13p' TEMP)
|
||||||
|
ADDRESS2=$(sed -n '14p' 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 "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
|
||||||
|
else
|
||||||
|
# Split Addresses
|
||||||
|
CITY=$(echo $ADDRESS2 | cut -d, -f1)
|
||||||
|
ADDRESS2=$(echo $ADDRESS2 | sed -e "s/$CITY, //")
|
||||||
|
|
||||||
|
STATE=$(echo $ADDRESS2 | cut -d" " -f1)
|
||||||
|
ZIP=$(echo $ADDRESS2 | cut -d" " -f2)
|
||||||
|
|
||||||
|
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
|
||||||
|
echo "All done sorting! You can find all the Files in $OUTPUTFOLDER!"
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
read -r -p "Do you want to continue? [Y/n]" response
|
||||||
|
response=${response,,} # tolower
|
||||||
|
if [[ $response =~ ^(y| ) ]] || [[ -z $response ]]; then
|
||||||
|
cd $PDFDIR
|
||||||
|
for FILENAME in $PDFDIR/*
|
||||||
|
do
|
||||||
|
echo $FILENAME
|
||||||
|
#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}')
|
||||||
|
#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 $OUTPUTFOLDER/Statement-Pages-$LOCATION.pdf
|
||||||
|
then
|
||||||
|
mv $OUTPUTFOLDER/Statement-Pages-$LOCATION.pdf $OUTPUTFOLDER/temp.pdf
|
||||||
|
pdfunite "$FILENAME" $OUTPUTFOLDER/temp.pdf $OUTPUTFOLDER/Statement-Pages-$LOCATION.pdf
|
||||||
|
else
|
||||||
|
#IF the file doesn't exist create the file with the merge.
|
||||||
|
pdfunite "$FILENAME" $OUTPUTFOLDER/Statement-Pages-$LOCATION.pdf
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
echo "All done, you can find the PDF statments at $OUTPUTFOLDER."
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
exit
|
||||||
Executable
+62
@@ -0,0 +1,62 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#get directory for pdf files
|
||||||
|
#get output directory for files
|
||||||
|
|
||||||
|
|
||||||
|
#Get the folder with the pdf documents in it.
|
||||||
|
#echo "This will take the PDF statements that have been sorted and will merge them into PDF files based on the numbers of pages in the statement."
|
||||||
|
#echo ""
|
||||||
|
#echo "Before we begin we need a little information."
|
||||||
|
#echo ""
|
||||||
|
#while :
|
||||||
|
#do
|
||||||
|
# echo "Where is the directory that has the PDF statments with address?"
|
||||||
|
# read PDFDIR
|
||||||
|
# if [ -d $PDFDIR ]
|
||||||
|
# then
|
||||||
|
# break
|
||||||
|
# else
|
||||||
|
# echo "Directory not found."
|
||||||
|
# fi
|
||||||
|
#done
|
||||||
|
|
||||||
|
#Get the folder for the output file.
|
||||||
|
#while :
|
||||||
|
#do
|
||||||
|
# echo ""
|
||||||
|
# echo "What output directory do you want for the sorted PDF's?"
|
||||||
|
# read OUTPUTFOLDER
|
||||||
|
# #OUTPUTFOLDER="/home/btmccrea/Downloads/output"
|
||||||
|
# if [ -d $OUTPUTFOLDER ]
|
||||||
|
# then
|
||||||
|
# break
|
||||||
|
# else
|
||||||
|
# echo "Directory not found."
|
||||||
|
# fi
|
||||||
|
#done
|
||||||
|
|
||||||
|
cd $PDFDIR
|
||||||
|
for FILENAME in $PDFDIR/*
|
||||||
|
do
|
||||||
|
echo $FILENAME
|
||||||
|
#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}')
|
||||||
|
#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 $OUTPUTFOLDER/Statement-Pages-$LOCATION.pdf
|
||||||
|
then
|
||||||
|
mv $OUTPUTFOLDER/Statement-Pages-$LOCATION.pdf $OUTPUTFOLDER/temp.pdf
|
||||||
|
pdfunite "$FILENAME" $OUTPUTFOLDER/temp.pdf $OUTPUTFOLDER/Statement-Pages-$LOCATION.pdf
|
||||||
|
else
|
||||||
|
#IF the file doesn't exist create the file with the merge.
|
||||||
|
pdfunite "$FILENAME" $OUTPUTFOLDER/Statement-Pages-$LOCATION.pdf
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "All done, you can find the PDF statments at $OUTPUTFOLDER.
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
exit
|
||||||
Reference in new issue
Block a user