整理照片
Workflow
graph TD
T1[Workflow 1: 管理照片] -.-> E
E[用iPhone拍摄照片]
E --> G[用数据线将照片导入PC]
G --> H[用自动化脚本(见下文)将照片按拍摄日期整理]
H --> C[将整理后的照片上传到NAS存储]
C --> D[通过PiGallery2提供照片服务]
D --> B[随时在任意设备上浏览PiGallery2上的照片]
T2[Workflow 2: 备份硬盘] -.-> I
I[定期通过restic备份照片到外接移动硬盘]
Script
# 0. Enter photos folder
cd /mnt/d/Downloads/DCIM
# 1. Rename & reorganize photos by date
# Ref: https://linux.die.net/man/1/exiftool
exiftool '-filename<CreateDate' -d /mnt/d/Downloads/Photos/OrganizedPhotos/%Y/%Y_%m/%Y_%m_%d/%Y-%m-%d_%H%M%S%%-c.%%le -r .
# 2. Remove all AAE files
# Ref: https://superuser.com/questions/112078/delete-matching-files-in-all-subdirectories
find . -name \*.AAE -type f -delete
# 3. Move all no-exif photos
# Ref: https://unix.stackexchange.com/questions/52814/flattening-a-nested-directory
find . -mindepth 2 -type f -exec mv -t /mnt/d/Downloads/Photos/PhotosWithoutEXIFDates -n '{}' +
# 4. Check if duplicate photos exist
# Ref: https://serverfault.com/questions/267255/mv-rename-if-exists
find . -mindepth 2 -type f -exec mv -t . -n '{}' +