Skip to content

Instantly share code, notes, and snippets.

@klieret
Created March 10, 2018 09:22
Show Gist options
  • Save klieret/940263410e654b6ee1c54610e99e562c to your computer and use it in GitHub Desktop.
Save klieret/940263410e654b6ee1c54610e99e562c to your computer and use it in GitHub Desktop.
#!/bin/bash
# script to go through all figures, search all of our *.tex
# files to see if the figure is still included, and
# if not, print it to standard output
# pipe to rm to delete the unused ones then.
set -e
latex_dir=""
if [[ ! -n "${latex_dir}" ]]; then
echo "Please enter the full path for 'latex_dir' in the script."
echo "Abort."
exit 10
fi
# separate by spaces; dir names must not include spaces
figureDirs="${latex_dir}/rendered/"
for dir in ${figureDirs}; do
cd "${dir}"
for file in *; do
count=$(find ${latex_dir} -name "*.tex" | xargs grep $file | wc -l)
if (( "$count" == 0 )); then
echo "${dir}/${file}"
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment