My script loops through all subsubdirectories and calls pdflatex command on all .tex files:
#!/usr/bin/env bash
shopt -s globstar
for d in ./*/**/*.tex; do
echo pdflatex "$d"
done
My question
How to set the current working directory to the current subsubdirectory in the loop?
Similar question: How to set current working directory to the directory of the script?
Why I ask
My .tex files contain relative path and that's why the compiler only works if the current working directory is the directory where the file is.