...
 
Commits (6)
......@@ -2,16 +2,22 @@
Shell script for QNAP NAS appliances to import and organize photos and RAW files. The script transfers photos and RAW files from an external storage device to the specified directory on the QNAP NAS. For each JPEG photos, the script writes camera model, lens, and weather conditions to the EXIF metadata. The script then renames the transferred files using the YYYYMMDD-HHMMSS format and groups them into folders by date.
# Intstallation and Usage
# Installation and Usage
The [Linux Photography](https://gumroad.com/l/linux-photography) book provides detailed instructions on installing and using Momo. Get your copy at [Google Play Store](https://play.google.com/store/books/details/Dmitri_Popov_Linux_Photography?id=cO70CwAAQBAJ) or [Gumroad](https://gumroad.com/l/linux-photography).
<img src="https://scribblesandsnaps.files.wordpress.com/2016/07/linux-photography-6.jpg" width="200"/>
## Usage
momo.sh -d <dir> -g <location>
`-d` or `--directory` absolute path to the source directory
`-g` or `--geotag` name of the city where the photos were taken (optional)
## Limitations
- Momo assumes that the photos and RAW files transferred during an import operation are taken is one city.
- Momo can handle photos and RAW files stored in the specified source directory, and the script ignores subdirectories.
When using the script to geotag photos, Momo assumes that all transferred photos and RAW files are taken is one city.
## Problems?
......
......@@ -89,6 +89,7 @@ if [ ! -f "$CONFIG" ]; then
fi
source "$CONFIG"
mkdir -p "$target"
echo
echo "---------------------"
......@@ -96,8 +97,14 @@ echo "Transferring files..."
echo "---------------------"
echo
rsync -avh --progress "$src" "$target"
results=$(find "$src" -type f -iname "*.JPG" -o -iname "*.ARW")
lines=$(echo -e "$results" | wc -l)
for line in $(seq 1 $lines)
do
file=$(echo -e "$results" | sed -n "$line p")
echo "$file"
cp "$file" "$target"
done
cd "$target"
if [ ! -z "$location" ]; then
......@@ -115,21 +122,33 @@ if [ ! -z "$location" ]; then
else
lonref="W"
fi
fi
echo
echo "--------------"
echo "Geotagging ..."
echo "--------------"
echo
exiftool -overwrite_original -GPSLatitude=$lat -GPSLatitudeRef=$latref -GPSLongitude=$lon -GPSLongitudeRef=$lonref -ext JPG .
fi
results=$(find "$target" -type f -iname "*.JPG")
lines=$(echo -e "$results" | wc -l)
for line in $(seq 1 $lines)
do
file=$(echo -e "$results" | sed -n "$line p")
exiftool -overwrite_original -GPSLatitude=$lat -GPSLatitudeRef=$latref -GPSLongitude=$lon -GPSLongitudeRef=$lonref "$file"
done
# Check whether the Dark Sky API is reachable
check2=$(wget -q --spider https://api.darksky.net/)
if [ -z "$check2" ]; then
echo
echo "-------------------------"
echo "Writing EXIF metadata ..."
echo "-------------------------"
echo
# Obtain and write copyright camera model, lens, and weather conditions
for file in *.JPG
for line in $(seq 1 $lines)
do
file=$(echo -e "$results" | sed -n "$line p")
lat=$(exiftool -gpslatitude -n "$file" | cut -d":" -f2 | tr -d " ")
lon=$(exiftool -gpslongitude -n "$file" | cut -d":" -f2 | tr -d " ")
t=$(exiftool -d %Y-%m-%d -DateTimeOriginal "$file" | cut -d":" -f2 | tr -d " " | xargs -I dt date --date=dt +"%s")
......@@ -153,8 +172,8 @@ echo "--------------------------"
echo "Renaming and organizing..."
echo "--------------------------"
echo
exiftool -d %Y%m%d-%H%M%S%%-c.%%e '-FileName<DateTimeOriginal' .
exiftool '-Directory<CreateDate' -d ./%Y-%m-%d .
exiftool -r -d %Y%m%d-%H%M%S%%-c.%%e '-FileName<DateTimeOriginal' "$target"
exiftool -r '-Directory<CreateDate' -d ./%Y-%m-%d "$target"
if [ -f "$json" ]; then
rm "$json"
......