#!/bin/sh ## This function will clean TeX/LaTeX project folders recursively. if [ -z "$1" ]; then WORKDIR="$PWD" else WORKDIR="$1" fi ## First we need to get the name of a .tex file, and then we can remove ## associated extensions in current folder. We proceed this way so that we do ## not remove incidentally files matching these extensions even if they are not ## linked to a TeX file in any manner. while read -r FILE; do FILE_NOEXT="${FILE##*/}" FILE_NOEXT="${FILE_NOEXT%.*}" FILE_PATH="${FILE%/*}" find "$FILE_PATH" -maxdepth 1 -type f \( \ -name "$FILE_NOEXT.aux" -o \ -name "$FILE_NOEXT.glg" -o \ -name "$FILE_NOEXT.glo" -o \ -name "$FILE_NOEXT.gls" -o \ -name "$FILE_NOEXT.idx" -o \ -name "$FILE_NOEXT.ilg" -o \ -name "$FILE_NOEXT.ind" -o \ -name "$FILE_NOEXT.lof" -o \ -name "$FILE_NOEXT.log" -o \ -name "$FILE_NOEXT.maf" -o \ -name "$FILE_NOEXT.mtc" -o \ -name "$FILE_NOEXT.mtc?" -o \ -name "$FILE_NOEXT.nav" -o \ -name "$FILE_NOEXT.out" -o \ -name "$FILE_NOEXT.snm" -o \ -name "$FILE_NOEXT.synctex" -o \ -name "$FILE_NOEXT.synctex.gz" -o \ -name "$FILE_NOEXT.tns" -o \ -name "$FILE_NOEXT.toc" -o \ -name "$FILE_NOEXT.xdy" \) \ -print \ -delete done <