Created
April 16, 2021 15:36
-
-
Save arnaudlimbourg/acc8cdae56a00d0f52557739420af96b to your computer and use it in GitHub Desktop.
Delete images files which names cannot be found in the code base
This file contains 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
IMAGES_LOCATION="./" | |
FILES=`find $IMAGES_LOCATION -not -name '*.scss'` | |
# loop through the file list, exclude the extension to be very safe | |
# and remove the files that have no match. This approach is conservative | |
# since we might keep files that are no used due to a different extension | |
# but it should not happen a lot | |
for FILE in $FILES; do | |
FULLNAME=$(basename "$FILE") | |
BASE="${FULLNAME%%.*}" | |
# git grep $BASE > /dev/null || echo "Would remove $BASE ($FILE)" | |
git grep $BASE > /dev/null || git rm $FILE | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment