ambevar-dotfiles/.scripts/texclean

37 lines
859 B
Bash
Executable File

#!/bin/sh
if [ $# -eq 0 ] || [ "$1" = "-h" ]; then
cat <<EOF
Usage: ${0##*/} FOLDERS
Clean TeX/LaTeX/Texinfo project folders recursively.
First we look for .tex or .texi files, and then we can remove associated
extensions in current folder. We proceed this way so that we do not incidentally
remove files matching these extensions if they are not linked to a TeX file in
any manner.
EOF
exit
fi
for i ; do
while read -r FILE; do
case FILE in
*/*) ;;
*)
FILE="./$FILE" ;;
esac
DIRNAME="${FILE%/*}"
BASENAME="${FILE##*/}"
BASENAME="${BASENAME%.*}"
rm -v $(
for j in aux bbl blg cp cps fn glg glo gls idx ilg ind ky lof log maf mt mtc nav out pg snm synctex.gz synctex tns toc tp vr vrs xdy
do
echo "$DIRNAME/$BASENAME.$j"
done) 2>/dev/null
done <<EOF
$(find "$i" -type f \( -name "*.tex" -o -name "*.texi" \) )
EOF
done