42 lines
978 B
Bash
Executable File
42 lines
978 B
Bash
Executable File
#!/bin/sh
|
|
|
|
usage () {
|
|
cat <<EOF>&2
|
|
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
|
|
}
|
|
|
|
[ $# -eq 0 ] && usage && exit 1
|
|
[ "$1" = "-h" ] && usage && exit
|
|
[ "$1" = "--" ] && shift
|
|
|
|
for i ; do
|
|
while read -r file; do
|
|
case "$file" in
|
|
*/*) ;;
|
|
*)
|
|
file="./$file" ;;
|
|
esac
|
|
dirname="${file%/*}"
|
|
basename="${file##*/}"
|
|
basename="${basename%.*}"
|
|
## Reset arg list (big performance boost).
|
|
set --
|
|
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
|
|
set -- "$@" "$dirname/$basename.$j"
|
|
done
|
|
rm -v "$@" 2>/dev/null
|
|
done <<EOF
|
|
$(find "$i" -type f \( -name "*.tex" -o -name "*.texi" \) )
|
|
EOF
|
|
done
|