aboutsummaryrefslogtreecommitdiff
path: root/bin/jsonGen
blob: 3e2d13f15f2699c0a2181fd50bdd9463db709b3f (plain) (blame)
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
#!/bin/bash

echo "usage: jsonGen <path> <library> <orig-extemsion>"

echo "[" > "content.json"

for file in $1; do
    filename=$(basename -- "$file")
    extension="${filename##*.}"
    originalFile="$2$(echo "$filename" | cut -d "." -f 1).$3"
    
    echo "  {" >> "content.json"
    #if [ -f "$originalFile" ]; then
        COORDS=$(exiftool -c "%.6f" "$originalFile" | grep "GPS" | grep Position | cut -d ':' -f 2)
        NORTH=$(echo "$COORDS" | cut -d "," -f 1 | tr "N" "" | tr " " "")
        EAST=$(echo "$COORDS" | cut -d "," -f 2 | tr "E" "" | tr " " "")
        echo "    \"fileName\": \"$filename\"," >> "content.json"
        echo "    \"time\": \"2020-07-23T$(echo "$filename" | cut -d "." -f 1 | tr "-" ":") UTC+2\"" >> "content.json"

       echo "FILE: '$filename', NORTH: '$NORTH', EAST: '$EAST'"
     #   if [ -z "$COORDS" ]; then
            #echo "FILE: '$filename', NORTH: '$NORTH', EAST: '$EAST'"
                   
    #    fi
        
    #fi
    echo "  }," >> "content.json"

    echo "Not in library: '$filename'."
done

echo "]" >> "content.json"