-
Notifications
You must be signed in to change notification settings - Fork 0
/
script
executable file
·49 lines (36 loc) · 1.31 KB
/
script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
if [ $# = 2 ]; then
if [ -d "$1" ]; then
if [ -d "$2" ]; then
# se le due cartelle esistono
dir1=($1/*.jpg) # array di immagini nelle due cartelle
dir2=($2/*.jpg)
corretto=1
if [ ${#dir1[@]} = ${#dir2[@]} ]; then # se il numero dei file nelle 2 cartelle e' uguale procedo
echo "Both folders have ${#dir1[@]} images"
for ((i=0;i<${#dir1[@]};i++)); do # scorro i file nelle due cartelle e confronto se hanno la stessa checksum
output1=( $(md5sum ${dir1[i]}) )
output2=( $(md5sum ${dir2[i]}) )
#echo ${output1[0]} ${output2[0]}
if [ ${output1[0]} != ${output2[0]} ]; then
corretto=0
break
fi
done
if [ $corretto = 1 ]; then
echo "Same files in the two folders"
else
echo "NOT same files in the two folders"
fi
else
echo "NOT same files number in the two folders"
fi
else
echo " $2 does not exist"
fi
else
echo " $1 does not exist"
fi
else
echo "To execute the script: ./script nomecartella1 nomecartella2"
fi