Keeping a Kapadokya Trip Archive Readable After Five Years

这篇内容暂时只有 English 版本,以下是原文。

A friend who runs a small guesthouse in Göreme asked me to look at their trip archive last spring: five years of guest photos, scanned maps, and short video clips, about 1.8 TB, sitting on two USB drives that had been swapped between an office laptop and a reception PC. Nothing was lost yet, but the folder tree had become unusable. Turkish characters in filenames had been mangled by a Windows-to-Linux round trip, and a good number of files had names like IMG_0432 (1).JPG repeated across years. The drives were exFAT, which meant no permissions and no reliable timestamps after a copy.

I did not try to rename everything by hand. I wrote a small script that walks the tree, reads EXIF where available, and falls back to the file’s modification time only when EXIF is missing. The key part is normalising names to ASCII while keeping the original Turkish spelling in a sidecar index, so a search for Kapadokya still works even if the on-disk name became kapadokya. The snippet below is the core loop; it assumes exiftool is installed and that you are running it from the archive root.

#!/usr/bin/env bash
set -euo pipefail
find . -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.mp4' \) -print0 \
  | while IFS= read -r -d '' f; do
      ts=$(exiftool -s3 -DateTimeOriginal -d '%Y%m%d-%H%M%S' "$f" 2>/dev/null || true)
      if [ -z "$ts" ]; then ts=$(date -r "$f" +%Y%m%d-%H%M%S); fi
      base=$(basename "$f" | iconv -f UTF-8 -t ASCII//TRANSLIT | tr ' ' '_')
      dir=$(dirname "$f")
      printf '%s\t%s\t%s\n' "$ts" "$base" "$f" >> index.tsv
    done

The reason for the sidecar index instead of in-place renaming is that in-place renames are irreversible once you have more than a few hundred files, and the drives had already been copied back and forth. The index lets the guesthouse search by original name, date, or camera while leaving the files untouched. The cost is an extra file that has to travel with the archive; if someone copies only the photo folders, the index is lost and the Turkish names are gone. That is a real trade-off, not a free win.

Where this breaks: files with no EXIF and a modification time reset by a copy will be dated to the copy, not the trip. I hit that on about 200 files from a 2019 tour that had been moved through a FAT32 drive. Also, iconv on macOS and on some minimal Linux images handles //TRANSLIT differently, so the same filename can map to two different ASCII strings. I ended up pinning the script to run on one machine and recording the hostname in the index header, which is ugly but honest. One more pitfall: exiftool is slow on video, so a 1.8 TB tree took most of an afternoon; run it with -fast if you only need dates.

What I would like to know from people who have kept archives across multiple machines: do you keep the original filenames and rely on a search index, or do you rename once and accept that the mapping is stored somewhere else? I have gone back and forth, and I am not sure the index approach survives a non-technical owner who moves folders around.

0
赞同度 100% · 0 条评论 · 2 阅读

0 条评论

支持 Markdown · 回复会实时推送给对方

还没有评论,写下第一条。