Repository: examplecode/unused-image
Branch: master
Commit: d43c811c0211
Files: 2
Total size: 2.3 KB
Directory structure:
gitextract_kxqxan1x/
├── README.md
└── unused-image.sh
================================================
FILE CONTENTS
================================================
================================================
FILE: README.md
================================================
# unsed-image
This shell script is used to check and clean unused image file in your project directory,supoort Android and IOS.
## show unused image file
./unused-image.sh -p /path/of/your/project
## show and clean unused image file
./unused-image.sh -r -p /path/of/your/project
================================================
FILE: unused-image.sh
================================================
#!/bin/sh
PROGNAME=$(basename "$0")
PROGDIR=$(dirname "$0")
usage()
{
echo "Usage: $PROGNAME [option] -p path-of-project"
echo ""
echo "-p Specifyed the path of your project"
echo "-r Remove unused image file"
echo "-h Show this message"
exit 1
}
PRJ_ROOT=$1
REMOVE=false
COUNT=0
while getopts ":rp:" optname
do
case "$optname" in
"p")
PRJ_ROOT=$OPTARG # specifyed the project root
;;
"r")
REMOVE=true # remove unused image resource
;;
"?")
usage
;;
":")
echo "No argument value for option $OPTARG"
;;
*)
# Should not occur
echo "Unknown error while processing options"
;;
esac
#echo "OPTIND is now $OPTIND"
done
check_files=`find $PRJ_ROOT -name '*.xib' -o -name '*.storyboard' -o -name '*.[mh]' -o -name '*.pch' -o -name '*.java' -o -name '*.xml'`
for png in `find $PRJ_ROOT -name '*.png'`
do
match_name=`basename $png`
suffix1="@2x.png"
suffix2=".9.png"
suffix3=".png"
suffix4="@3x.png"
if [[ ${match_name/${suffix1}//} != $match_name ]]; then
match_name=${match_name%$suffix1}
elif [[ ${match_name/${suffix4}//} != $match_name ]]; then
match_name=${match_name%$suffix4}
elif [[ ${match_name/${suffix2}//} != $match_name ]]; then
match_name=${match_name%$suffix2}
else
match_name=${match_name%$suffix3}
fi
dir_name=`dirname $png`
if [[ $dir_name =~ .bundle$ ]] || [[ $dir_name =~ .appiconset$ ]] || [[ $dir_name =~ .launchimage$ ]]; then
continue
fi
referenced=false
for file in `echo $check_files | sed 's/\n/ /g'`
do
if grep -sqh "$match_name" "$file"; then
referenced=true
fi
done
if ! $referenced ; then
echo "The '$png' was not referenced in any file"
COUNT=`expr $COUNT + 1`
if $REMOVE ; then
echo "Do remove unused image file '$png'"
rm -f $png
fi
fi
done
echo "============= Total $COUNT unused image files ============="
gitextract_kxqxan1x/ ├── README.md └── unused-image.sh
Condensed preview — 2 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (3K chars).
[
{
"path": "README.md",
"chars": 295,
"preview": "# unsed-image\n\nThis shell script is used to check and clean unused image file in your project directory,supoort Android"
},
{
"path": "unused-image.sh",
"chars": 2072,
"preview": "#!/bin/sh\n\nPROGNAME=$(basename \"$0\")\nPROGDIR=$(dirname \"$0\")\n\nusage()\n{\n\techo \"Usage: $PROGNAME [option] -p path-of-pr"
}
]
About this extraction
This page contains the full source code of the examplecode/unused-image GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 2 files (2.3 KB), approximately 760 tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.