Advertisement
Guest User

Untitled

a guest
Jul 5th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. GREEN='\033[0;32m'
  4. RED='\033[0;31m'
  5. YELLOW='\033[0;33m'
  6. NC='\033[0m'
  7.  
  8. rm unused_files.log &> /dev/null
  9.  
  10. grep -r . --include=\*.meta --exclude=*{Editor,Gizmos}* -e 'guid' | while read line; do
  11. guuid=`echo $line | awk '{print $NF}'`
  12. path=`echo $line | awk '{print $1}' | cut -f1 -d":"`
  13. no_meta=`echo $path | sed "s/.meta$//"`
  14. # Skip if is directory
  15. if [[ -d $no_meta ]]; then
  16. continue
  17. fi
  18.  
  19. filename=$(basename "$path")
  20. filename="${filename%.*}"
  21.  
  22. echo -e "${GREEN}Currently searching for $guuid in $filename${NC}"
  23. grep -rn . --include=\*.{unity,anim,controller,prefab,mat} -e $guuid
  24. if [[ $? != 0 ]]; then
  25. echo $filename | grep .cs$ && is_script=$? || is_script=$?
  26. echo $filename | grep .unity$ && is_map=$? || is_map=$?
  27.  
  28. if [[ $is_script == 0 ]]; then
  29. echo -e "${YELLOW}FILE $path not used directly, searching...${NC}"
  30. grep -rn . --include=\*.cs --exclude=$no_meta -e "${filename%.*}"
  31. if [[ $? != 0 ]]; then
  32. echo -e "${RED}FILE $path is unused!!!${NC}"
  33. echo $path >> unused_files.log
  34. fi
  35. elif [[ $is_map == 0 ]]; then
  36. echo -e "${YELLOW}FILE $path not used directly, searching...${NC}"
  37. grep ProjectSettings/EditorBuildSettings.asset -e `echo $no_meta | sed "s/^\.\///"`
  38. if [[ $? != 0 ]]; then
  39. echo -e "${RED}FILE $path is unused!!!${NC}"
  40. echo $path >> unused_files.log
  41. fi
  42. else
  43. echo -e "${RED}FILE $path is unused!!!${NC}"
  44. echo $path >> unused_files.log
  45. fi
  46. fi
  47. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement