0

I have created small bash script which finds the unused images(*.jpg and *.png) in iOS project. And here is the code for the same.

//For removing space and replace '\n' in file and folder names

`IFS=$'\n'` 

//Find all files with extension *.png and *.jpg

`for i in `find . -name "*.png" -o -name "*.jpg"``; do` 

//Get the base name of found file

file=``basename -s .jpg "$i" | xargs basename -s .png`` 

//Replace "\n" with original space so that ack can search exact file name in all files 

filenameWithSpace="${file//$'\n'/ }" 

//Merge both basename and extension for ack command
//Add this "</dev/null" to ack command for it to work on jenkins setup

`extension="${i##*.}"` 

`filename="$filenameWithSpace.$extension"`

result=`ack -i --ignore-file=match:/.\.pbxproj/ "$filename" </dev/null`

//result=ack -i "$filename" </dev/null
//If result is NULL then ack did not find any occurrence of the filename in any file

`if [ -z "$result" ];`

`then `

`echo "$i" `

`fi `

`done` 

Should ".pbxproj" be included in my search? I ask this question since including and excluding ".pbxproj" provides me different results.

Thanks in advance.

Vinodh
  • 5,262
  • 4
  • 38
  • 68
Anand Reddy
  • 61
  • 1
  • 3

1 Answers1

0

Don't include the .pbxproj. It will have the image references.

FYI : http://jeffhodnett.github.io/Unused/ to find the unused images.

Praveen Matanam
  • 2,773
  • 1
  • 20
  • 24