AutomationProjects

Drive Auto-Sort — no iCloud, the HDD sorts photos itself

Today it runs quietly every 5 minutes, with no screen, no notifications and nothing to press. Drop photos into Inbox, go do something else, and when you come back they're already in their folders.

12 min read

Drop photos into a single Inbox folder and the Mac works out which ones are bank transfer slips, which are screenshots and which are cats, using the Vision framework that already ships with macOS. Photos travel from the iPhone to the hard drive at home over Tailscale: no cable, no port opened to the internet, no monthly fee.

BashSwiftCVision.frameworkThai OCRTailscaleSMBlaunchdon-device
Empathize · Define

The real pain point wasn't the storage fee

The starting brief was “I don't want to pay for iCloud.” But one more question, what am I actually paying for, reshaped the whole problem.

Hard drive with the cover off, showing the platter inside
A hard drive that's already paid for, with plenty of space, but nobody to put things away · Photo: Nick / Unsplash

I already had a big enough, fully paid-for hard drive plugged into my Mac, but it was just a place to dump files, not a library where I can find things. What iCloud really sells isn't gigabytes. It's things landing in the right place without me doing anything.

— The point of view that changed the whole brief

Once the problem was framed this way, the most sensible-looking fix, “just drag the files onto the HDD,” turned out to be worse. It swaps a monthly fee for manual effort paid every time a file comes in.

The real cost is the labor of sorting, not the space

A subscription is paid once per billing cycle. Sorting by hand costs attention every time something arrives, and that's a cost nobody keeps paying for long.

A folder nobody sorts becomes a folder nobody opens

Moving files to the HDD without anything to sort them leaves one pile of thousands of files you can't search. In the end you don't dare delete them and never open them, which is worse than leaving them on the phone.

A file extension tells you it's a photo, not what the photo is

My existing sorter could only send .jpg to Photos and .pdf to Documents. That's enough for documents but not for photos: with thousands of photos in one folder, I still couldn't find last month's slip.

Every existing solution asks you to upload private photos to the cloud

The services that are genuinely good at photo search all run on the provider's servers. Financial slips and photos of home have to leave the machine before you get the convenience back.


Ideate

Four options weighed honestly before deciding to build it myself

Three criteria: sort photos by what's in them · no ongoing cost · photos never leave the machine

iPhone taking a photo of mountains by a lake
Photos are taken on the phone every day. The task is getting them to the hard drive on their own without trading that for a cloud upload · Photo: Josh Power / Unsplash
OptionSorts by contentCostWhy it was rejected / chosen
iCloud+ Searchable, but doesn't organize folders Monthly, forever Photos live on Apple's servers · paying still doesn't give a folder structure I can reuse, and it's the very thing the brief wanted to avoid
Google Photos Best search of the group Monthly once over quota All financial slips and private photos have to go up to Google's servers, a price I don't want to pay in a different sense
NAS + photo app Yes, with extra plugins Hardware + upkeep It stays at home, but means buying a whole new set of hardware to solve a problem my existing HDD and Mac can already handle
Extend my existing sorter Chosen Yes, with Vision built into macOS None Photos stay on the HDD I already have · an extension-based sorter already runs, it just needs one more layer that looks at the content
The deciding factor

The Vision framework already ships with macOS. It can classify images into 1,303 categories and read text in 30 languages, Thai included. It runs on the device, with no internet, no API key and no per-call cost. Everything needed was already on the machine; it only had to be wired up correctly.


Ideate · Prototype

To really replace iCloud, photos have to get from the phone to the hard drive on their own

However smart the sorter is, it means nothing if I have to plug the iPhone into the computer every time. The piece that makes the whole system a real cloud replacement is this path.

Mockup of the Files app on iPhone: connecting to the home Mac's smb server and dropping 6 photos into the Inbox folder
Mockup of the steps on iPhone: Connect to Server over Tailscale, then drop photos into Inbox (the real machine name is replaced with a sample one)

Plug in a cable and transfer every time

This is the old workflow that meant nobody actually did it. If you have to wait until you're home and find a cable, the photos just keep piling up on the phone.

Forward port 445 to the internet on the router

SMB is one of the most heavily scanned ports on the internet. Opening it directly for personal convenience is a bad trade, and it also needs dynamic DNS to keep up when the home IP changes.

Set up my own VPN into the house

The right result, but it means touching router settings, opening ports and managing keys and certificates myself. That's ongoing sysadmin work just to move photos.

The chosen route — Tailscale

A mesh VPN built on WireGuard that lets the iPhone and Mac talk directly over the tailnet's private IP, which stays the same no matter which network either device is on. No port forwarding, no dynamic DNS, not a single line of router config, and nothing exposed to the public internet.

iPhone — from anywhere
Files appConnect to ServerPick photos and drop
↕
Tailscale — WireGuard mesh
Fixed private IPNo relay server in betweenNo port forwarding
↕
macOS File Sharing — a share named Drive
SMB on port 445Listens on the tailnet onlyGuest access off
↕
HDD at home — Drive/Inbox
launchd picks it up within 5 minutesVision assigns a categoryInto Photos/<category>
  • Port 445 never appears on the public internet — it listens on the tailnet only, which is entirely different from forwarding a port on the router
  • Guest access is off — you have to log in with the machine's account; being on the tailnet alone isn't enough
  • No tailscale serve or funnel set up at all — not a single service is exposed outside the tailnet
  • HDD not plugged in = the share simply disappears — the sorter also exits quietly, as designed, with no errors to chase

Prototype

Three files, each with a reason to be separate

They're not split to look systematic. macOS limitations forced the split.

Terminal showing line counts for three files: drive 178 lines, drivesort.c 10 lines, imgclass.swift 28 lines, and drive selftest passing
Three files, 216 lines in total — real output of wc -l and drive selftest

drive — bash

All the logic lives here · sort sorts files · offload moves things to the HDD and leaves a symlink behind · selftest checks itself before any change

drivesort — C, 8 lines

macOS won't grant Full Disk Access to a shell script, so a real binary is needed to hold the permission. Only this binary gets disk access, instead of granting it to /bin/bash system-wide.

imgclass — Swift

bash can't call system frameworks itself. This does one job: open Vision and print the raw result, either labels for what's in the photo or the text it can read.

launchd — wakes every 5 minutes
No real-time folder watchingHDD not plugged in = quiet exit, not an error
↕
drive sort — first pass by extension
PhotosVideosDocumentsDesignUnknown = stays in Inbox
↕
imgclass — on-device Vision
VNClassifyImageRequestVNRecognizeTextRequestth-TH + en-US
↕
Photos/ — 7 subfolders
slipscreenshotdogcatfoodplantsky

Prototype

How it works — 5 steps

From a file that just landed in Inbox to its destination folder, without anyone pressing anything

Orange cat next to a terminal running imgclass, which returns the labels animal cat feline mammal, and a plant photo returning plant foliage
Real output of imgclass (on-device Vision, offline) — labels sorted from most to least confident, then drive maps them to folder names · Cat photo: Amber Kipp / Unsplash
01

Wake every 5 minutes

No real-time folder watching. This job doesn't need second-level speed, and waking on a schedule is cheaper than keeping a process running all the time.

02

Only pick up files untouched for over 1 minute

Skip recently modified files so a photo the phone is still uploading doesn't get moved half-finished into the wrong place.

03

First pass by extension

Photos · Videos · Documents · Design — unknown extensions aren't guessed; they stay in Inbox for a person to decide

04

Only photos go to Vision

Returns labels for what's in the photo, ordered by confidence · only if it looks like a screenshot does OCR run to read the text, since OCR is several times slower

05

Into a subfolder, or nowhere

Not confident = no guessing. It stays in Photos/ for a person to decide, the same rule as unknown extensions.


Define

The order of the checks decides the result, not the model's accuracy

A photo always gets several labels at once. Which folder it ends up in depends on which question is asked first.

Sample slip next to a terminal: Vision returns document and screenshot, then OCR finds the Thai words for transfer successful, recipient and transaction number, so it goes to the slip folder
To Vision a slip is just a “screenshot” — it has to read the text and check slip before screenshot (real run on a mock slip made for this, not a real one)
Screenshot + finance words found
→ slip
A slip captured from an app matches both slip and screenshot, so slip has to be checked first
Screenshot
→ screenshot
Whatever's left after the step above is an ordinary screenshot
Has a dog label
→ dog
Animals are always checked before plants
Has a cat label
→ cat
A cat standing in front of a bush gets both cat and plant. If plants were checked first, every cat photo would vanish into the plant folder.
Has a food label
→ food
Vision already tags every dish with food, so there's no need to list menu items one by one — and it's checked before plants for the same reason as animals: a dish with a leaf garnish is still a food photo
Has a plant label
→ plant
—
Sky, and only in the top 2 labels
→ sky
Almost every outdoor photo comes with sky. Without requiring it to be prominent, everything would become a sky photo.
Matches nothing
→ not moved
Stays in Photos/ for a person to decide
Tested on a real photo

For a black cat standing in front of a shrub, Vision returns animal mammal cat feline together, and because cats are checked before plants, the file lands in Photos/cat, not Photos/plant


Test & Iterate

Three things I only learned by measuring against real files

Each one was an assumption that sounded reasonable on paper and turned out wrong when measured

Crumpled paper receipt on a white surface
Having receipt in the label list doesn't mean Vision recognizes slips from banking apps · Photo: Michael Walter / Unsplash

I assumed Vision would recognize slips because its list has a label called receipt

Tested on 60 real slips, the receipt label never came back once. 59 of them got document and screenshot, all the same, because real slips aren't paper receipts photographed with a camera. They're screen captures from banking apps, which look exactly like screenshots.

Fix: if the image can't tell them apart, read the text on it instead. Vision supports Thai OCR, so it reads the image and looks for Thai words meaning reference code, PromptPay and amount paid. Because OCR is much slower than image classification, it only runs on images already classified as screenshots.

The word “fee” pulled stock purchase confirmations in as slips

When I built the list of words that mark a slip, I included the Thai word for fee because transfer slips often have it. Measured against 25 ordinary screenshots, 3 stock purchase confirmations were pulled in as slips because they also contain the word fee.

Fix: drop that word and keep only words specific enough not to show up in other kinds of financial documents. Measured again after the change, no ordinary screenshot was misfiled as a slip — lesson: a word that “usually appears” is not the same as a word that “only appears here.”

Among the 1,303 labels are words that look alike but mean different things

Vision's list includes hotdog prairie_dog eggplant cauliflower sunflower_seeds bobcat goldfish jellyfish. With substring matching, a hot dog photo becomes a dog photo, an eggplant becomes a plant, and an aquarium becomes dinner.

Fix: match whole lines only, never substrings. The fix took under a minute, but without reading through the entire label list first, there would have been no way to know it was needed.

Test

Measured against my own files, not a sample dataset

Folders I had already sorted by hand became a free answer key to check results against

Terminal running drive sort, moving 8 files from Inbox into Photos/cat plant slip screenshot, next to a Finder window showing the subfolders and 4 cat photos
Real run on 8 sample files: drive sort moves everything into subfolders and Inbox is empty — the Finder window shows the actual result on disk
Test setCountResult
Hand-sorted slip folder67 photos53 as slip · 8 as screenshot · 1 unsorted — opening the 8 misses showed they were chats, TikTok clips and signatures that had actually been mixed into the folder, not slips
Hand-sorted screenshot folder5 photosAll correct, 5 of 5
Ordinary screenshots outside the drive25 photosNone misclassified as a slip
Real Inbox, on the real run18 filesAll 18 files matched the dry run before moving — cat 8 · slip 8 · plant 1 · screenshot 1
18/18
Files sorted into the right folder on the real Inbox run
0
Ordinary screenshots misfiled as slips
5/5
Hand-sorted screenshot answer key
1
Category with no real photos to test yet: dogs
The most valuable number in this table is zero

A sorter that occasionally gets things wrong is tolerable, since you'll find them when you open the folder. A tool that hides things in the wrong place is worse than no tool at all. So one rule held throughout the project: if it's not sure, it doesn't guess.


Define

Scope I deliberately left out

What was cut matters more to the tool's reliability than what was added

Black and white photo of a hard drive
Not sure, don't guess — files that don't meet the criteria always wait for a person to decide · Photo: Frank R / Unsplash
  • No guessing when unsure — a file staying where it is beats being moved somewhere its owner can't find
  • No external services at all — financial slips and private photos shouldn't be uploaded anywhere in exchange for tidy folders
  • No sorting logic in Swift — the classifier just prints raw output and the mapping to folder names lives in the script, so adding a category doesn't need a recompile
  • A missing HDD isn't treated as a failure — the job ends quietly and tries again next round, with no warning every 5 minutes
  • Already-sorted old files are left alone — it only handles new arrivals in Inbox; sorting the backlog is a call the owner should make

Tan · Natpakan Sirirat

Product Designer & AI Builder — designing user experiences and building AI tools that actually work.

0%