Start with installing pdftk (Debian)
sudo apt install pdftk
For Ubuntu 18.04, use the pdftk image from the snap store
sudo snap install pdftk
For Ubuntu 18.04 on WSL, install pdftk from this PPA:
sudo add-apt-repository ppa:malteworld/ppa
sudo apt update
sudo apt install pdftk
Then rotate all PDF's in the current directory
for file in *.pdf; do pdftk "$file" cat 1-endeast output "${file%.pdf}-rotated.pdf"; done
Replace 1-endeast
with 1-endwest
to rotate in the opposite direction.
Lastly, if you're happy with results, remove un-rotated pdfs
ls | grep -v rotated.pdf | tr "\n" "\0" | xargs -0 rm
and rename back to original filenames
sudo apt install rename
rename 's/-rotated\.pdf$/\.pdf/' *.pdf