Created
December 31, 2016 22:14
-
-
Save moose-byte/bfe1913b3d49e183d68b1b684e9c88e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# pdftotextOnDir | |
# Runs pdftotext on all files in a directory | |
# Author - Brendan Heussler ([email protected]) | |
# argument 1 - Input Directory | |
# argument 2 - Output Directory | |
input_directory=$1 # Input Directory | |
output_directory=$2 # Output Directory | |
# Check to see if the input directory exists | |
if [ -d "$input_directory" ]; then | |
echo "Input Directory Exists" | |
else | |
echo "Input Directory Does Not Exist" | |
echo "Terminating $0" | |
exit 1 | |
fi | |
# Check to see if the output directory exists | |
if [ -d "$output_directory" ]; then | |
echo "Output Directory Exists" | |
else | |
echo "Output Directory Does Not Exist" | |
echo "Creating Output Directory" | |
mkdir $output_directory | |
fi | |
# Run pdftotext on all files in the input directory | |
for file in $input_directory* | |
do | |
echo "Running pdftotext on $file" | |
file_basename=$(basename $file .pdf) | |
output_filename=${file_basename}.txt | |
pdftotext "$file" "$output_directory$output_filename" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment