Skip to content

Instantly share code, notes, and snippets.

@yglodt
Created February 7, 2019 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yglodt/28de98354e1f2e45ede9bb5939ea0234 to your computer and use it in GitHub Desktop.
Save yglodt/28de98354e1f2e45ede9bb5939ea0234 to your computer and use it in GitHub Desktop.
#!/bin/bash
# 54321_xxxxxx_yyyyy.pdf
# 54321_xxxxxx_yyyyy.pdf
# 54321_xxxxxx_yyyyy.pdf
# will become 54321.pdf
# 54322_xxxxxx_yyyyy.pdf
# 54322_xxxxxx_yyyyy.pdf
# will become 54322.pdf
cd /mnt/c/TEMP/pdfs
list="";
for file in *pdf; do
if [ -f "$file" ]; then
#echo "$file"
num="${file:0:5}"
list="$list $num"
fi
done
#echo $list
uniques=$(echo $list | tr ' ' '\n' | sort -nu)
#echo $uniques
for uni in $uniques; do
echo "Creating $uni ..."
pdfunite $(echo "$uni"_*) "merged/$uni.pdf"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment