Skip to content

Commit 82485bb

Browse files
author
Alessandro Gubitosi
committed
Added first script version
1 parent 908308e commit 82485bb

1 file changed

Lines changed: 210 additions & 0 deletions

File tree

strip_exif

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
#!/bin/bash
2+
3+
# Exiftool commands
4+
# @see https://exiftool.org/TagNames.pdf
5+
# ----------------------------------------------------------------------------
6+
7+
declare -A osInfo;
8+
osInfo[/etc/redhat-release]="yum"
9+
osInfo[/etc/arch-release]="pacman"
10+
osInfo[/etc/gentoo-release]="emerge"
11+
osInfo[/etc/SuSE-release]="zypp"
12+
osInfo[/etc/debian_version]="apt-get"
13+
osInfo[/etc/alpine-release]="apk"
14+
for f in ${!osInfo[@]}
15+
do
16+
if [[ -f $f ]];then
17+
package_manager=${osInfo[$f]}
18+
fi
19+
done
20+
21+
# Correct args if the filepath does not exists
22+
if [ ! -f "$2" ] && [ ! -d "$2" ]; then
23+
for ARG in "$@"; do
24+
if [ "$ARG" != "$1" ]; then
25+
filepath+=$ARG
26+
fi
27+
done
28+
else
29+
filepath=$2
30+
fi
31+
32+
33+
# ----------------------------------------------------------------------------
34+
35+
echo ""
36+
echo -e "\e[36m================================================================================\e[0m"
37+
echo -e "\e[1;33m
38+
, ,^. .
39+
,'| _ \ / _ |\`.
40+
/ / \`.\| |/,' \ \\
41+
/ : \`. ,' : \\
42+
: | | | | :
43+
| : ; : ; |
44+
: \`.__,' \`.__,' ;
45+
\ /
46+
\ /
47+
\`. ,'
48+
\`-._______,-'
49+
50+
JOIN THE RESISTANCE
51+
\e[0m"
52+
echo -e "\e[1;36m--------------------------------------------------------------------------------\e[0m"
53+
echo -e "
54+
\e[1mQuesto script rimuove i metadati cattivi dai files\e[0m, anche conosciuti come
55+
\"Copyright\" (obbligo al non-uso/non-divulgazione).
56+
Sebbene il riconoscimento delle fonti è un atto più che doveroso e legittimo,
57+
il Copyright e il \"diritto d'autore\" sono un'invenzione diabolica dell'Impero
58+
di Alpha Draconis per impedire la divulgazione della conoscenza tra le persone e
59+
obbligarle a sottostare alle sue leggi draconiane e al terribile sistema di
60+
dominio attraverso la finanza a debito.
61+
62+
Crediamo fermamente alla libera conoscenza e siamo contrari ad ogni sua forma di
63+
impedimento.
64+
Se hai un file - qualunque esso sia - è una pura forma di conoscenza e non devi
65+
sentirti obbligato/a ad alcunché."
66+
echo -e "\e[36m================================================================================\e[0m"
67+
echo ""
68+
69+
if [ ! "$1" ] || [ ! "$2" ] ; then
70+
if [ "$1" != "read" ] && [ "$1" != "clean" ]; then
71+
echo -e "\e[31m\e[1m×\e[0m \e[31mManca l'operatore principale.\e[0m"
72+
fi
73+
if [ ! "$2" ] ; then
74+
echo -e "\e[31m\e[1m×\e[0m \e[31mManca un file o una directory da esaminare.\e[0m"
75+
fi
76+
77+
echo ""
78+
echo "Sintassi:"
79+
echo -e " \e[38;5;240m\$>\e[0m ./strip_exif [\e[92mread\e[0m|\e[93mclean\e[0m] \e[96mfile\e[0m|\e[96mdirectory\e[0m"
80+
echo ""
81+
exit
82+
fi
83+
84+
# Check if package is not installed
85+
pkg="exiftool"
86+
package_installed=$(dpkg-query -l | grep "$pkg" | wc -l)
87+
if [ "$package_installed" -eq 0 ]; then
88+
while true; do
89+
# Ask if user wants to install it
90+
read -p "$pkg non sembra essere installato, procedere con l'installazione? [y|n] " yn
91+
case $yn in
92+
[Yy]* )
93+
sudo $package_manager install -y $pkg
94+
95+
# Ok the package is installed
96+
if [ "$package_installed" -eq 1 ]; then
97+
echo ""
98+
echo "--------------------------------------------------------------------------------"
99+
echo "$pkg installato correttamente."
100+
echo ""
101+
fi
102+
break;;
103+
[Nn]* )
104+
echo "Ok, ciao :)"
105+
exit;;
106+
* ) echo "Per cortesia rispondi: digita \"y\" per \"\" o \"n\" per \"No\".";;
107+
esac
108+
done
109+
fi
110+
111+
# ----------------------------------------------------------------------------
112+
113+
if [ "$1" == "clean" ]; then
114+
read -r -d '' strip_data << EOF
115+
-AOCopyrightNotice=
116+
-AOCurrentCopyrightOwnerId=
117+
-AOCurrentCopyrightOwnerName=
118+
-AOCurrentCopyrightOwnerName=
119+
-AOCurrentLicensorId=
120+
-AOCurrentLicensorName=
121+
-ArtworkCopyrightNotice=
122+
-ArtworkCopyrightOwnerID=
123+
-copyright=
124+
-Copyright=
125+
-CopyrightFileName=
126+
-CopyrightFlag=
127+
-CopyrightLen=
128+
-CopyrightLicenseCountryCode=
129+
-CopyrightLicenseRegionCode=
130+
-CopyrightLicenseRegionName=
131+
-CopyrightNotice=
132+
-CopyrightOwner=
133+
-CopyrightOwnerID=
134+
-CopyrightOwnerImageID=
135+
-CopyrightOwnerName=
136+
-CopyrightRegistrationNumber=
137+
-CopyrightStatus=
138+
-CopyrightStatus=
139+
-CopyrightURL=
140+
-CopyrightYear=
141+
-CurrentIPTCDigest=
142+
-HistoryAction=
143+
-HistoryInstanceID=
144+
-IPTCDigest=
145+
-LegalCopyright=
146+
-LegalCopyrights=
147+
-LegalTrademark=
148+
-LegalTrademarks=
149+
-lookCopyright=
150+
-LookCopyright=
151+
-MDItemCopyright=
152+
-ProfileCopyright=
153+
-ProviderCopyright=
154+
-RecordingCopyright=
155+
-Trademark=
156+
-Trademarks=
157+
158+
-comment=
159+
-Comment=
160+
-description=
161+
-Description=
162+
-keywords=
163+
-notes=
164+
-Notes=
165+
-rights=
166+
-Rights=
167+
-Warning=
168+
169+
-Producer=
170+
171+
-ifd0:all=
172+
-iptc:all=
173+
-xmp:all=
174+
--copyright
175+
EOF
176+
# -api "filter=s/[©®™]/ /g"
177+
178+
echo ""
179+
echo "Procedo con la pulizia..."
180+
echo ""
181+
182+
# Check if passed filepath is a file or a directory
183+
if [ -d "$filepath" ]; then
184+
echo -e "$filepath è una \e[1mdirectory\e[0m. Pulizia ricorsiva..."
185+
echo ""
186+
# Run exiftool command
187+
exiftool -r -m -P -overwrite_original "$strip_data" "$filepath"
188+
# Read all metadata and output to file
189+
exiftool -r "$filepath" > "strip_exif_data.txt"
190+
elif [ -f "$filepath" ]; then
191+
echo -e "$filepath è un \e[1mfile\e[0m, lo pulisco..."
192+
echo ""
193+
exiftool -m -P -overwrite_original "$strip_data" "$filepath"
194+
# Read all metadata and output to file
195+
exiftool "$filepath" > "strip_exif_data.txt"
196+
else
197+
echo "$filepath non è un file o una directory valida"
198+
echo "";
199+
fi
200+
201+
echo ""
202+
echo -e "\e[32mFatto!\e[0m"
203+
echo ""
204+
fi
205+
206+
if [ "$1" == "read" ] || [ "$1" == "clean" ]; then
207+
echo -e "\e[34mLettura dei metadati:\e[0m"
208+
209+
exiftool "$filepath"
210+
fi

0 commit comments

Comments
 (0)