mirror of
https://github.com/SinTan1729/random.git
synced 2024-12-25 20:58:37 -06:00
33 lines
933 B
Bash
33 lines
933 B
Bash
#!/bin/sh
|
|
|
|
# I use it to clean up latex build files from a directory after I'm done with the project.
|
|
# Just run it inside the directory with the files.
|
|
# Depends on trash-cli
|
|
# Pass "-delete" to delete files instead of trashing.
|
|
|
|
if [ "$1" = "--delete" ]; then
|
|
read -p "Warning: Deleting instead of trashing. Continue? [y/N]: " resp
|
|
if [ $resp != "y" ] && [ $resp != "Y" ]; then
|
|
exit
|
|
fi
|
|
d=1
|
|
else
|
|
echo "Trashing files by default, pass --delete to delete instead."
|
|
d=0
|
|
fi
|
|
|
|
for f in *.tex; do
|
|
if [ -f "$f" ]; then
|
|
h=$(basename "$f" .tex)
|
|
echo "Removing files accompanying $h.tex..."
|
|
for g in "$h".*; do
|
|
k=$( echo $g | sed 's/^.*\.//')
|
|
if [ "$k" != "tex" ] && [ "$k" != "pdf" ] && [ "$k" != "bib" ] ; then
|
|
echo "Removing $g..."
|
|
[ $d -eq 0 ] && trash "$g" || rm "$g"
|
|
fi
|
|
done
|
|
fi
|
|
done
|
|
|
|
echo "Done!"
|