-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathordfotos.sh
More file actions
executable file
·29 lines (29 loc) · 847 Bytes
/
ordfotos.sh
File metadata and controls
executable file
·29 lines (29 loc) · 847 Bytes
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
#!/bin/sh
echo "** Renombrador de fotos a fecha de captura v0.01 **"
if [ -z "$1" ]; then
echo "No has proporcionado la ruta de los ficheros"
echo "Uso: `basename $0` ruta"
echo ""
exit
fi
# Changing Internal Field Separator variable to prevent 'for' loops splitting with the whitespace character
OLD_IFS=$IFS
IFS=$(echo -en "\n\b")
#for i in `ls $1 | grep -i jpg`; do
for i in `find $1 -iname "*.jp*" -type f -print`; do
if [ -f "$i" ]; then
echo -n "Now working on $i... "
extension=`echo "$i" | sed 's/.*\.//' | tr "[:upper:]" "[:lower:]"`
creationDateTime=`jhead "$i" | grep Date/Time | awk '{ print $3"_"$4 }' | sed 's/://g'`
mv "$i" "$1/$creationDateTime.$extension"
if [ $? -eq 0 ]; then
echo OK
else
echo FAIL
fi
else
echo "El fichero $i no existe"
fi
done
IFS=$OLD_IFS
exit