Organize your WhatsApp media files into conversation-based folders using the msgstore database and contacts.
This tool takes your WhatsApp media files (images, videos, audio, documents) and organizes them into folders by conversation/contact, instead of having everything mixed together in one big folder.
Before:
WhatsApp/Media/
WhatsApp Images/
IMG-20240101-WA0001.jpg
IMG-20240102-WA0002.jpg
...
WhatsApp Video/
VID-20240101-WA0001.mp4
...
After:
Media_organized/
John Doe/
Images/
IMG-20240101-WA0001.jpg
Video/
VID-20240101-WA0001.mp4
Family Group/
Images/
IMG-20240102-WA0002.jpg
...
WhatsApp's media management is deliberately terrible. You can't organize files by conversation, you can't bulk export organized archives, and you're stuck with a chronological dump of thousands of files with cryptic names. This is by design to keep you locked into their ecosystem.
Your data belongs to you. Organize it however you want.
This README has two paths depending on your technical comfort level:
- ๐ค For Regular Users - Detailed step-by-step guide with clear explanations
- ๐ป For Developers - Concise technical reference
- Android phone with WhatsApp
- USB cable to connect phone to computer
- About 30 minutes
- Your Google Contacts (optional but recommended)
- Open WhatsApp on your phone
- Tap โฎ (three dots) โ Settings
- Go to Chats โ Chat backup
- Tap End-to-end encrypted backup โ Turn on
- Select Use a 64-digit encryption key (NOT password!)
- SAVE THIS KEY! Screenshot it, write it down, put it in a password manager
- Tap Create โ Done
โ ๏ธ Critical: This key is really important! Without it, you can't recover your messages if you reinstall WhatsApp
- In WhatsApp: Settings โ Chats โ Chat backup
- Tap the big green Back up button
- Wait for it to finish (may take 10-30 minutes if your chats are big)
Method A: Google Contacts
- Go to contacts.google.com
- Sign in with the same Google account on your phone
- Click Export (arrow on the top-right)
- Choose vCard format โ Export
- Save as
contacts.vcf
Method B: Phone's Contacts App
- Open your Contacts app
- Find Import/Export or Settings
- Select Export to vCard file
- Save somewhere you can find it
What to copy:
Databasesfolder (contains encrypted backup)Mediafolder (all your images, videos, etc.)contacts.vcffile (from Step 3)
How:
- Connect phone to computer via USB
- On phone: Tap the USB notification โ Select File Transfer
- On computer: Open your phone in file explorer
- Navigate to:
Internal storage/Android/media/com.whatsapp/WhatsApp/ - Copy the
DatabasesandMediafolders to your computer - Also copy your
contacts.vcfif you saved it on phone
๐ก Tip: Create a folder on your computer called WhatsApp_Export and put everything there.
Windows:
- Download from python.org/downloads
- Run the installer
- โ CHECK "Add Python to PATH"
- Click "Install Now"
Mac:
brew install python@3.10Linux:
sudo apt install python3.10 python3-pip # Debian/Ubuntu
sudo dnf install python3.10 python3-pip # FedoraOpen Terminal/Command Prompt (Windows: Win+R โ type cmd โ Enter):
# Navigate to your WhatsApp export folder
cd path/to/WhatsApp_Export
# Install decryption tool
pip install wa-crypt-tools
# Install organizer
pip install git+https://github.com/yourusername/wa-sort-media.gitwadecryptWhen prompted, paste your 64-digit key from Step 1. This creates encrypted_backup.key.
wadecrypt decrypt encrypted_backup.key Databases/msgstore.db.crypt15 msgstore.dbYou should see: "Decryption successful!"
๐ If your database has a date like
msgstore-2026-01-20.1.db.crypt15, use that name instead.
Test with dry-run first (doesn't actually move files):
wasort msgstore.db Media --contacts contacts.vcf --dry-run -vIf it looks good, run for real:
# Copy files (keeps originals)
wasort msgstore.db Media --contacts contacts.vcf --copy
# OR move files (deletes originals)
wasort msgstore.db Media --contacts contacts.vcf --moveWatch the progress bars! When done, check the Media_organized folder.
If you aren't familiar with Androidโs security model, here's why extracting WhatsApp data has historically been a significant hurdle:
On Android, every app runs in its own "sandbox." WhatsApp stores its encryption key and internal databases in a private directory:
/data/data/com.whatsapp/files/key
Directories on the /data folder are only accessible by the apps own UID or by the Root user. Without Root access, a user or a third-party desktop tool cannot "see" or copy this key.
While WhatsApp creates backups on your local storage (msgstore.db.crypt15, wa.db.crypt15), these files are useless without the key mentioned above.For a long time, all methods to get the key were fragile, hacky, inconvenient or all of the above.
- Rooting: Gaining root access to directly read /data/data/com.whatsapp/databases/.
- Voids warranty (for those who care) and can brick the device if you're careless. Triggers Google's SafetyNet/Play Integrity check, breaking many banking apps and requiring workarounds (Magisk). Most critically, it forces a full re-login and reverification of WhatsApp, which is the primary point of failure for data preservation.
- Downgrading: Installing an older WhatsApp version with known vulnerabilities or legacy backup formats.
- Highly unstable. Older versions often crash or fail to read current data structures. The re-login process on an old version frequently triggers server-side data wipes or account locks, leading to irreversible local data loss.
- Legacy ADB Backups: Using adb backup to request app data.
- Effectively dead. WhatsApp disabled support, and Google deprecated the functionality. Does not work on Android 9+. Any tools claiming otherwise use patched ADB binaries or exploit CVE-2014-7956, which are unreliable.
Thankfully, WhatsApp has now introduced now supports End-to-End Encrypted Backups using a user-generated 64-digit encryption key, finally bypassing all of the problems above.
As of Jan 2026, the 64-digit E2E encryption token is the ONLY reliable way to access your WhatsApp database for non-rooted users.
-
Install Tools:
pip install wa-crypt-tools git+https://github.com/chances190/wa-sort-media.git
-
Pull Files from Phone (ADB Method):
- Ensure ADB is installed and your phone is connected in file transfer mode.
adb pull /storage/emulated/0/Android/media/com.whatsapp/WhatsApp/Databases . adb pull /storage/emulated/0/media/com.whatsapp/WhatsApp/Media .
-
Pull Real wa.db (Root Only):
- Requires root access on your device.
- The
wa.dbin backups is practically empty, it's just a stub with minimal data.
adb shell su -c "cp /data/data/com.whatsapp/databases/wa.db /storage/emulated/0/" adb pull /storage/emulated/0/wa.db .
-
Decrypt Database:
- Run interactively to create the key file:
wadecrypt
- Paste your 64-digit token when prompted.
- Then decrypt the database:
wadecrypt decrypt encrypted_backup.key Databases/msgstore.db.crypt15 msgstore.db
-
Organize Media:
- Using Google Contacts VCF:
wasort msgstore.db Media --contacts contacts.vcf
- Or using wa.db:
wasort msgstore.db Media --wa-db wa.db
wasort <msgstore.db> <media_folder> [output_folder] [options]Arguments:
msgstore.db- Decrypted WhatsApp databasemedia_folder- Your WhatsApp Media folderoutput_folder- (Optional) Where to put organized files (default:<media_folder>_organized)
Options:
--contacts <file.vcf>- Use Google Contacts VCF export--wa-db <wa.db>- Use WhatsApp's wa.db--copy- Copy files (keeps originals) - Default--move- Move files (removes originals)--dry-run- Show what would happen without doing it-v/--verbose- Show detailed progress
- Huge thanks to TripCode for creating the original WhatsApp crypt12 decrypter, which laid the foundation for all subsequent encryption research and tools.
- Thanks to ElDavoo for creating and maintaining wa-crypt-tools, which builds on that foundation to enable database decryption without root access.
- Thanks to YuvrajRaghuvanshiS and all contributors to the WhatsApp-Key-Database-Extractor and the broader community who've continued the work of reverse engineering WhatsApp's encryption.
- This tool wouldn't exist without the collective effort of these developers. ๐
- Thanks to the WhatsApp developers who implemented the E2E 64-digit token backup feature. The one good thing in this mess.