From 03b5b5d7df32e173e387bca7a0a81abf6f1b81b7 Mon Sep 17 00:00:00 2001 From: TRBC Developer <5380239-trbcdev@users.noreply.gitlab.com> Date: Wed, 24 Jan 2024 13:24:28 +0000 Subject: [PATCH] Update file Run.sh --- Run.sh | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/Run.sh b/Run.sh index 30ab80c..d1133da 100644 --- a/Run.sh +++ b/Run.sh @@ -64,27 +64,26 @@ do echo "Copying file to the folder called Addresses" fi done -echo "All done sorting!" You can find all the Files in $OUTPUTFOLDER!" +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 +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}') + 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 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 + pdfunite "$FILENAME" $OUTPUTFOLDER/Statement-Pages-$LOCATION.pdf fi done echo