Created
March 10, 2018 09:22
-
-
Save klieret/940263410e654b6ee1c54610e99e562c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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