-
Notifications
You must be signed in to change notification settings - Fork 0
/
organizefiles.sh
32 lines (29 loc) · 920 Bytes
/
organizefiles.sh
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
# author: Don
# date: 08/08/18
# read exif information of jpg files in current directory
# and make a folder for date created, move the file into that directory
# helps you organize your image files
for f in *.JPG ;
do
w=`exiv2 $f| grep -i "image timestamp" `
yy=`echo $w | awk -F':' '{print $2}'`
mm=`echo $w | awk -F':' '{print $3}'`
dd=`echo $w | awk -F':' '{print $5}' |awk -F' ' '{print $1}' | awk -F' ' '{print $1}'`
dir=`echo $yy\_$mm\_$dd`
#echo $dir
len=`echo $dir|wc -c`
if [ $len -eq "11" ]
then
if [ -d $dir ]
then
echo "directory found $dir"
mv $f $dir
else
echo "creating directory $dir"
`mkdir $dir`
mv $f $dir
fi
else
echo "no metadata found for file=$f"
fi
done