I was wondering whether there is simple command to delete all unnecessary files generated during the latex compilation process, e.g. .aux, .log, etc.
It would be great to chain it to the regular Latex build commands, so that after I hit "Compile", the junk files are deleted.
As an editing tool, I'm using TeXstudio.
I created a shell script that does exactly what you want. It will work on Mac and Linux; with some adjustments Windows should be possible too. Download the file "cleanlatexjunk.sh" from my repository and follow the instructions:
https://github.com/cgraumann/LatexUtils
cleanjunk
"/PATH/TO/SCRIPT/cleanlatexjunk.sh" -fp ?me ?a)
and change /PATH/TO/SCRIPT/ accordingly
| txs:///compile | txs:///compile | txs:///cleanjunk
at the endNow every build & view execution should result in a clean workspace :-)
Edit: As mentioned by Werner in the comment, the "junk" files are of course needed during the build process. Therefore the suggested command in step 5 includes two additional compile runs. This assures that all TOCs and links are rendered correctly.