Salome HOME
OK surface plane
[modules/shaper.git] / find_duplicated_images.sh
1 #!/bin/bash
2
3 find_duplicated_images_usage()
4 {
5     echo "Find duplicated images."
6     echo
7     echo "Usage: $(basename ${0}) [options]"
8     echo
9     echo "Options:"
10     echo
11     echo "  --help (-h)        Print this help information and exit."
12     echo "  --print (-p)       List duplicated files. Default: OFF."
13     echo
14     exit 0
15 }
16
17
18
19 find_duplicated_images_main()
20 {
21     local verbose=0
22
23     local where=$(readlink -f $(dirname "${0}"))
24
25     # parse command line
26     local option
27     while getopts ":-:hp" option ${@}
28     do
29         if [ "${option}" = "-" ]
30         then
31             case ${OPTARG} in
32                 help ) find_duplicated_images_usage ;;
33                 print ) verbose=1 ;;
34                 * ) echo "Wrong option: --${OPTARG}" > /dev/stderr ; exit 1 ;;
35             esac
36         else
37             case ${option} in
38                 h ) find_duplicated_images_usage ;;
39                 p ) verbose=1 ;;
40                 ? ) echo "Wrong option" > /dev/stderr ; exit 1 ;;
41             esac
42         fi
43     done
44     shift $((OPTIND - 1))
45     
46     local result=0
47
48     if [ "${verbose}" = "1" ]
49     then
50         local filename
51         for filename in $(find ${where} -type f -wholename "*/doc/*.png" -exec basename {} \; | sort | uniq -d)
52         do
53             find ${where} -type f -wholename "*/doc/*/${filename}"
54             result=$((result+1))
55         done
56     else
57         result=$(find -type f -wholename "*/doc/*.png" -exec basename {} \; | sort | uniq -d | wc -l)
58     fi
59
60     return ${result}
61 }
62
63 find_duplicated_images_main "${@}"