39 lines
921 B
Bash
Executable File
39 lines
921 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%.*}"
|
|
## 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
|