Recover Anything
Your deleted photos are probably still there. Get them back safely, with one command or by asking your AI agent.
Deleted photos from your camera? Formatted the wrong SD card? Seeing "this card needs to be formatted"? Recover Anything reads the card without ever writing to it. It finds every photo, video and document it can, and rebuilds photos that were stored in scattered pieces. Original file names come back even after a format. It checks every file and gives you a sorted folder plus a plain-language report.
It's one pure-Python package with zero dependencies. It also ships a skill, so Claude Code or Codex can run the whole rescue for someone who has never opened a terminal.
Quick start
pipx install recover-anything
recover-anything devices # which disk is the card?
sudo recover-anything triage /dev/rdisk4 # honest odds, and what not to do
sudo recover-anything recover /dev/rdisk4 -o ~/Desktop/Recovered
Linux cards look like /dev/sdb or /dev/mmcblk0; Windows uses \\.\PhysicalDrive2 in an Administrator terminal. Reading a card directly needs administrator rights; the recovered files are handed back to your own user. You can also point it at a disk image.
You get a folder sorted by month, plus a report you can open in any browser:
Or let your agent do it
recover-anything install-skill # installs the skill for Claude Code and Codex
Then ask: "I formatted my camera's SD card by accident. Can you get my photos back?" The skill teaches the agent the rules a recovery expert follows:
- stop using the card
- never "repair" it
- copy it first
- never save onto it
- be honest about the odds
Results
Every number here is reproducible: recover-anything selftest for the table, recover-anything selftest --stress 9 for the stress test. It builds simulated SD cards (FAT32 and exFAT, camera-style photos with EXIF and thumbnails) and wrecks them the way people do. Then it runs the real recovery and compares every recovered file byte for byte with the original.
| Simulated card | Filesystem | Recovered byte for byte | Kept original names | Notes |
|---|---|---|---|---|
| Accidentally deleted (63 photos + 1 video) | FAT32 | 64 / 64 (100%) | 64 | |
| Formatted | FAT32 | 64 / 64 (100%) | 64 | names restored from folders that survived the format |
| Formatted, then 20 new photos taken | FAT32 | 43 / 43 (100%) of what survived | n/a | 20 old photos were physically overwritten by the new ones: gone for any tool |
| Heavily fragmented, then formatted | FAT32 | 60 / 60 (100%) | 60 | all 20 photos that were split into pieces rebuilt |
| Accidentally deleted | exFAT | 64 / 64 (100%) | 64 | |
| Formatted | exFAT | 64 / 64 (100%) | 64 | |
| Heavily fragmented, then formatted | exFAT | 60 / 60 (100%) | 60 | all 20 fragmented photos rebuilt |
Each card is a 4 GB SD card image with 32 KB clusters; each run takes 20 to 30 seconds on a 2-core cloud VM.
Stress test. We ran randomized cards with three rounds of shooting and deleting, mixed JPEG encoders (standard, optimized, restart markers, high quality) and 8 to 32 KB clusters. Each card was then formatted in-camera, which recreates the folders and erases the names. Across 9 randomized cards, it rebuilt 104 of 104 fragmented photos and 32 of 32 videos (12 of them fragmented), and recovered 432 of 432 files byte for byte. No file was ever marked recovered unless it matched the original exactly. The cards come from fixed seeds, so every run builds exactly the same cards.
These are simulated cards built to behave like real ones. Reports from real hardware are very welcome: open an issue with what happened and what came back.
What makes it different
- It never writes to your card. It opens the device read-only and copies it to an image first when there's room, and it never runs "repair" tools. Before saving anything, it works out every physical disk a write into the output folder could land on, by device identity rather than by path. It follows bind mounts, LVM and encrypted volumes, overlay and FUSE folders, disk images stored on the card (loop devices,
.dmg,.vhd), Windows links, junctions and\\?\paths, and network shares served by the computer itself. It refuses if any of them is the card, or if it can't tell. Each card copy is fingerprinted by its partition table, boot area and file listing, so one card's copy is never reused for another. - Fragmented photos and videos come back whole. When a camera fills the hole left by a deleted photo, the next photo (or video) is split across several places. After a format, ordinary carvers glue the pieces together in disk order, and you get the gray half-picture above. Recover Anything decodes each photo as it walks the card. It notices the moment the bytes stop belonging to that photo, then finds the piece that continues the picture. Videos are rebuilt using their own index, which lists where every frame must start. A photo only counts as recovered when its last block decodes, the image ends exactly where it should, and the picture matches the small preview the camera stored inside it; a video only counts when every frame is where its index says, and, if it was rebuilt from pieces, a frame start is checked right next to every place it jumps.
- Files still in the card's hidden trash come back too. Deleting from a card on a Mac, a Linux PC or (for USB drives) Windows moves files into a hidden trash folder on the card itself, still whole. An Android phone's gallery keeps deleted photos on the card for 30 days, hidden under a new name. Recover Anything copies them back by default, under their original names, and
triagetells you they're there. - Original names survive a format. A quick format wipes the file table but usually leaves folders like
DCIM/100CANONsitting in the data area. Recover Anything finds them, so you getIMG_0042.JPGback instead off12345678.jpg. - Every file is checked, and the report says how. Photos are decoded block by block. H.264/HEVC videos have every frame's position and header checked against their own index, and iPhone photos (HEIC) every tile's. PNG, ZIP and Office files have their checksums verified. PDF objects and compressed streams, AVI frames and GIF pictures are checked too. Formats whose contents can't be checked (a RAW's sensor data, WAV) only count as recovered if they were never deleted; otherwise they're saved and labeled. Anything incomplete or damaged goes to a separate Partly recovered folder with a label, rather than being dropped.
- Honest odds.
triagetells you up front when recovery is unlikely: internal SSDs with TRIM, drives that already blanked the deleted files, encrypted volumes (APFS volumes are read for their own encryption flag; Android "phone storage" cards and VeraCrypt-style disks are recognized), cards that were fully erased. A formatted card whose photos sit at its start isn't called erased: triage reads the start of the card, where cameras write first. A phone or camera plugged in by USB isn't a disk;devicessays to take the card out and use a card reader. - The report doesn't oversell. The headline counts only files whose check passed ("60 photos recovered; 2 more saved that you should open to make sure"), each badge comes from the file's status first, and the files to open are listed in the terminal, in
recovery.jsonand in--json. Without a terminal, a long run prints a progress line every 30 seconds with the time left (JSON lines with--json). - It looks everywhere else too. When the bytes are gone,
huntsearches the other places a copy can survive (see below).
When an AI agent (or rm -rf) deleted your files
recover-anything hunt --project ~/code/myapp # everything that lived in that folder
recover-anything hunt "thesis.docx" --save ~/Desktop/Found # copy whatever it finds
hunt is read-only and checks:
- Claude Code transcripts, which contain every file the agent wrote, edited or fully read.
huntreplays them to rebuild the latest version. - Codex session logs (files it created).
- Git: commits lost to
reset --hardor a rebase, staged-but-never-committed content, and stashes. - Editor history: VS Code, Cursor and Windsurf local history, and JetBrains Local History.
- The trash or Recycle Bin.
- Snapshots: Time Machine local snapshots, Windows shadow copies and File History, and btrfs, ZFS and Timeshift snapshots.
- Desktop thumbnail caches, which keep small previews of deleted photos.
It also lists the cloud places to check by hand: Google Photos trash, iCloud Recently Deleted, Google Drive, OneDrive, Dropbox, and the chats you sent the file in.
How it works
flowchart LR
A[Card, disk or image] -->|read-only| B[Partitions and filesystem]
B --> C[Folder tree: live and deleted entries]
B --> D[Lost folders that survived a format]
B --> E[Carve every sector]
C --> F{Check every file}
D --> F
E --> F
F -->|broken photo| G[Rebuild from fragments]
G --> F
F -->|whole| H[Name, de-duplicate, sort by date]
H --> I[Recovered folder + report.html + recovery.json]
- Filesystem pass. FAT12/16/32 and exFAT are parsed directly. Deleted entries keep their name, size, date and first cluster. On exFAT they usually also say whether the file was stored in one piece.
- Lost folders. Directory clusters still in the data area after a format are recognized by their structure and stitched back into paths. A top folder holding only
100CANON-style folders is namedDCIMagain. - Carving. Every 512-byte sector of the whole device is checked for the signatures of more than 20 format families: photos (JPEG, HEIC, PNG, GIF, BMP, TIFF-based RAW, CR3, Photoshop), videos (MP4/MOV, dashcam and camcorder streams, MKV/WebM, AVI), audio (MP3, FLAC, Ogg/Opus, WAV, AMR), documents and archives (PDF, Office old and new, ZIP, RAR, 7z, gzip) and SQLite databases. Looking at every sector, not just cluster starts, finds files left over from an earlier format with a different layout. Each hit is measured to its exact length by parsing the format, not by guessing.
- Checking. A pure-Python baseline JPEG decoder walks the image data, and a deleted photo is compared with the preview the camera stored inside it. MP4/MOV sample tables and the item tables of iPhone photos (HEIC) are verified against the bytes they point to, MKV and WebM frames are checked one by one (H.264 and H.265 units, VP9 and VP8 headers and the sizes they give, AV1 units), and ZIP/Office members are decompressed and checksummed. FLAC, Ogg and gzip carry their own checksums, and so do PDF streams. AVI frames and GIF pictures are decoded, SQLite databases get SQLite's own integrity check, and recordings are checked frame by frame and against their own clocks. A file type that can't prove its contents (BMP, WAV, a RAW's sensor data, old Office, AMR, and MP4 or M4A files with no video frames to check) is only called recovered if it was never deleted; otherwise it is saved and labeled. A file that breaks a parser is labeled "could not be checked"; it never stops the run.
- Reassembly. For a broken photo, the reassembler skips clusters that belong to other verified files and tries candidate clusters in order. It decodes a few KB of each and scores how smoothly the picture continues across the seam. It keeps going until the decoder reaches the last block with exactly the right count. Then it compares the picture with the photo's own preview: a piece of another photo that happened to decode shows up as a stretch that doesn't match, and the reassembler tries other pieces there. If the evidence is ambiguous, it refuses to guess and saves the readable top of the picture instead. A piece that lies only at the very edge of the picture, which the preview doesn't show, can't be told from another photo's, so a photo finished with one is saved as "check that it opens". For a broken video, it finds the frame index (searching free clusters for it when it sits at the end of the file), then lays the frames out cluster by cluster. Every listed frame start is a checkpoint that random data almost never passes. Music, voice memos, dashcam and camcorder clips, gzip archives, Word and Excel files (and everything else stored as ZIP), PDFs, trail-camera videos (Motion-JPEG AVI), MKV and WebM videos and GIFs are rebuilt the same way, unit by unit: each member of an archive must match its checksum and each compressed part of a PDF its own, and the archive's directory or the PDF's table must list exactly what was found. A join is only trusted when a checksum or the recording's own clock confirms it, because another recording's frames look just like this one's. MP3 has no clock: a rebuilt song is only called recovered when each piece follows the last with nothing else that could have come between, and its frames' bookkeeping (the bit reservoir) carries on across the join. Otherwise it is saved as "check that it plays".
- Output. A file found inside another one (a RAW's preview, a photo stored in a ZIP, a frame of a Motion-JPEG video) is dropped only when the container's own structure points to it, so a damaged RAW can't swallow the photos after it. Files go into
Photos/2026-07/,Videos/…,Audio/,Documents/andPartly recovered/. Each file is named by its original name or capture time, given its original date, and de-duplicated. You also getreport.htmland arecovery.jsonthat records where every piece came from on the card.
Commands
| Command | What it does |
|---|---|
recover-anything devices |
List disks and cards, mark which one is your system disk |
recover-anything triage SOURCE |
Identify the filesystem, check how much data is still there (the start of the card in full, the rest by sampling), give honest odds and the don'ts |
recover-anything image SOURCE card.img |
Make a read-only copy first (uses GNU ddrescue when installed, otherwise skips and logs unreadable sectors) |
recover-anything recover SOURCE -o DIR |
Find, check, rebuild and save everything. --only photos,videos, --include-live, --direct, --fast, --deep, --json |
recover-anything hunt [QUERY] |
Look for surviving copies elsewhere. --project DIR, --save DIR, --json |
recover-anything selftest |
Reproduce the results table on simulated cards (needs Pillow). --stress N runs N randomized cards |
recover-anything install-skill |
Teach Claude Code / Codex to drive all of this safely |
Everything has --json for agents and scripts.
What's supported
- Filesystems with names and folders: FAT12, FAT16, FAT32, exFAT (SD, SDHC and SDXC cards, USB sticks, most cameras and drones), and NTFS (external drives, big USB sticks, Windows data drives). On NTFS a deleted file keeps a record of where all its pieces are, so it comes back whole, named and in its folder, even when it was stored in pieces, as long as no new file has taken over that record or its space.
- Anything else (HFS+, ext4, a wiped or unknown card, a card reformatted with different settings): carving still finds the files, without names. A damaged FAT32 or exFAT boot sector is read from its backup copy, and an image cut short by read errors is used as far as it goes. When the computer can't open a card at all ("this card needs to be formatted"), every file still listed on it is copied, not just the deleted ones.
- File types:
- Photos: JPEG, HEIC/HEIF, AVIF, PNG, GIF, WebP, BMP, Photoshop (PSD/PSB), RAW (CR2, CR3, NEF, ARW, DNG, ORF, RW2, PEF).
- Videos: MP4, MOV, M4V, 3GP, AVI, MKV, WebM, dashcam and camcorder clips (TS, MTS/M2TS, MPG/VOB/MOD).
- Audio: MP3, FLAC, Ogg/Opus, WAV, M4A, AMR.
- Documents and archives: PDF, DOCX, XLSX, PPTX, EPUB, DOC, XLS, PPT, Outlook MSG, ZIP, RAR, 7z, gzip, and SQLite databases (phone messages, browser history).
- Files the filesystem still names are recovered whatever their type.
- Fragment reassembly: baseline JPEG (what cameras and phones write); MP4/MOV/M4V/3GP video with H.264 or HEVC, guided by the video's own frame index; iPhone photos (HEIC), guided by their own tile table; MP3, FLAC, Ogg, dashcam and camcorder clips, gzip, Word/Excel/PowerPoint and other ZIP-based files, PDF, Motion-JPEG AVI, MKV/WebM and GIF, unit by unit.
- Platforms: Linux, macOS and Windows. CI runs the tests and self-test on all three (Linux with Python 3.9 and 3.13, macOS and Windows with 3.13). It also attaches real disk images (a FAT32
.dmgon macOS, a.vhdon Windows, loop devices on Linux) and checks that the save guard refuses every way of spelling the card. Reading raw devices on real Mac and Windows hardware hasn't been tried by us yet: reports welcome.
Honest limits
- Data that has been physically overwritten is gone. No software brings it back.
- Deleted files on internal SSDs with TRIM, on modern phones and on encrypted volumes are usually erased or unreadable.
triagesays so andhuntis the realistic path. - Video reassembly covers MP4/MOV/M4V/3GP with H.264 or HEVC video (what cameras, phones and drones record), MKV and WebM, dashcam and camcorder clips (
.TS,.MTS) and Motion-JPEG AVI. Clusters that fall entirely inside one large frame can't be checked on their own. When the evidence for one of them is ambiguous, or one sits right next to a place where the rebuilt video jumps, the video is saved but labeled not fully confirmed instead of being called recovered. (There, another deleted file's piece could stand in for one the video lost to a newer file, and every check would still pass.) The same goes for split HEIC photos, whose tiles are checked the same way. On cards with small clusters, most split videos end up labeled this way; on our simulated cards, most of them are still saved byte for byte. - Progressive JPEGs (rare from cameras, common from messaging apps and the web) can't be decoded here, so a deleted one is saved and labeled to open and check, never called recovered, and isn't reassembled. The same goes for a deleted photo with no preview stored in it: nothing can show that every piece is its own.
- Fragment reassembly needs the card's current filesystem layout; files left over from an earlier format with different settings are recovered when they're in one piece.
- Some files can't be checked by their contents: a RAW's sensor data, WAV, AMR and M4A audio, BMP pictures, old Office files (
.doc,.xls), camcorder MPEG (.MOD,.MPG), and video in a codec the checks don't read (they read H.264, HEVC and Motion-JPEG, plus VP8, VP9 and AV1 in MKV and WebM). A deleted one is saved and labeled rather than called recovered. - APFS and ext4 file names aren't recovered yet (their files are still carved). On NTFS, a new file soon takes over a deleted file's record, name and all: the sooner you stop using the drive, the more names survive. Files Windows compressed or encrypted aren't read.
- It's pure Python. Full block-by-block checking runs at roughly 1.5 MB/s per CPU core, spread across your cores. Every deleted or rebuilt photo is always checked in full. Photos still on the card are checked by structure plus a random sample when there are more than 8 GB of them (they're only copied with
--include-live).--deepchecks everything in full;--fastskips the full check and labels deleted photos to open and check.
Roadmap
- RAW reassembly; reassembly for videos without a surviving index
- Phone backups (iPhone/Android) and chat apps
- An MCP server, and a small desktop app for people who will never open a terminal
Contributing
Bug reports from real cards are the most valuable thing you can send. If something didn't come back, run recover-anything triage on the card and include the output (it contains no file contents). To add a disaster scenario, write a builder in src/recover_anything/simcard/scenarios.py and it becomes part of selftest. When a randomized card misses a file, python tools/debug_card.py SEED shows where each missed file really was and what the recovery found there.
git clone https://github.com/RuikunWang506/recover-anything && cd recover-anything
pip install -e ".[dev]"
pytest -q
recover-anything selftest --quick
License
MIT. Recover Anything reads disks; it does not bypass encryption or access devices you don't own. Use it on your own cards and drives.
Metadata
Release files for recover-anything 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| recover_anything-0.2.3.tar.gz | 290.1 kB | With provenance | Details for recover_anything-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| recover_anything-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for recover_anything-0.2.3-py3-none-any.whl |
Total release size: 531.8 kB
Release files / recover_anything-0.2.3.tar.gz
| Download URL | recover_anything-0.2.3.tar.gz |
|---|---|
| Size | 290.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8d4a7cb201562edc0415c8d70ae8a829d161baee2a61d61fe002f8c99d75189b
|
|
BLAKE2b-256 checksum How to use checksums |
a3eb5414333d2ed995c05bcd265d5d384f4880ee15b1316dc39e4047bbe083c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / recover_anything-0.2.3-py3-none-any.whl
| Download URL | recover_anything-0.2.3-py3-none-any.whl |
|---|---|
| Size | 241.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4c129abde8d3c0e9082fb825c671cd5edf3fd42b5350aebfca9c6e67d9408101
|
|
BLAKE2b-256 checksum How to use checksums |
4107802749f1527a632e53e2eea3913376c3f00e9fd6f4635ceb6ed9d373b3c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logSecurity for recover-anything 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for recover_anything-0.2.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.