Finished Find Addresses. Starte Remove and Sort scripts
This commit is contained in:
1 parent
b5f85b754f
commit
2fb552ed8a
3 files changed
+59
-8
No files matched your search
@@ -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
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/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.
|
||||
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
|
||||
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
#get directory for pdf files
|
||||
#get output directory for files
|
||||
|
||||
#Get the location of the PDF files
|
||||
echo "What is the location of the PDF files"
|
||||
read FILE
|
||||
|
||||
for FILENAME in $FILE
|
||||
do
|
||||
#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 /mnt/tmpfs/Statement-Pages-$LOCATION.pdf; then
|
||||
mv /mnt/tmpfs/Statement-Pages-$LOCATION.pdf /mnt/tmpfs/temp.pdf
|
||||
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.
|
||||
pdfunite "$FILENAME" /mnt/tmpfs/Statement-Pages-$LOCATION.pdf
|
||||
fi;
|
||||
#once everything else is doen Make the directory to place the files into
|
||||
#and copy the finished files into it.
|
||||
mkdir $FILE/Finished/
|
||||
cp -r /mnt/tmpfs/Statement-* $FILE/Finished/
|
||||
done
|
||||
exit
|
||||
Reference in new issue
Block a user