whatsapp-organizer-script - README.txt -------------------------------------- What does this script --------------------- Whatsapp Messenger has become a very frequent use phone application for many people. The way to get the sent/received media files is quite easy, by connecting the phone to the computer, or even from the phone app itself. But getting these files organized by conversation peer is a more complicated task. If you deal with hundreds/thousands of images/videos/voice notes, then it is even more difficult. And if you tend to empty storage moving files out of the phone, then the job will probably become simply unaffordable. whatsapp-organizer-script is a simple utility written in bash which analizes your messages database looking for media files. It tries to find those files inside directories on your computer filesystem (trying to match both filename and size), and distribute them (at the moment only copying) on folders per conversation, based on those threads where every media file appeared. The script has been tested on Windows 7, Windows 10 (both with cygwin installed) & Ubuntu Linux 14. Media and database files has been copied from an Android (MM) rooted phone with Whatsapp Messenger (mine is 2.17.296, .crypt12 msgstore.db format). The desktop workstation serves as recipient for these files, and as a host to run the whole process. It reads either the msgstore.db or the msgstore.db.crypt12 database. In the second case, it needs to get the crypto "key" file. Besides, the script has to read the wa.db database too... All these steps are difficult to accomplish from a non rooted phone. So at least, I am planning to prepare a customizable option to bypass the wa.db requirement, because the organizing process is not so dependant to it. Since August 2018, it runs partially under Termux for Android (tested on rooted phones with no gcc, no python, so with a previously decrypted msgstore.db database). Also, a native Android phone app is currently under development. At the moment I have no chance to test the script onto iOS/macOS, so I have no idea if these systems could take any kind of profit of this utility. But I hope so. Comments & feedback are welcome. Contact data is at the end of this file. Requirements ------------ - Android mobile phone with: · Whatsapp Messenger installed · root access, not strictly necessary but recommended (see related section at the TODO file section, explain workarounds for non-root phones) - Personal computer or any device (i.e. Android phone itself) with: · Bash shell interpreter (any Windows with cygwin installed, Linux, Unix...) · Ability to transfer, from the Whatsapp phone to that computer, any of these two groups of files: - /sdcard/WhatsApp/Media - /data/data/com.whatsapp/databases/msgstore.db - /data/data/com.whatsapp/databases/wa.db or - /sdcard/WhatsApp/Media - /sdcard/WhatsApp/Databases/msgstore.db.crypt12 - /data/data/com.whatsapp/files/key - /data/data/com.whatsapp/databases/wa.db Destination paths not indicated as they have to be customized at ./etc/whatsapp-organizer.cfg · sqlite3 · xxd utility (part of the package Vi IMproved) · git, not strictly necessary but recomended in order to track some version info. In case of crypted msgstore.db.crypt12, you would also need: · python interpreter (test succesfully with python2 and python3) · python2-pip or python3-pip (necessary to compile python modules) · phython2-devel or python3-devel (necessary to compile python modules) · gcc-g++ compiler (necessary to compile python modules) · pycrypto python module · pycryptodome python module Install: -------- - In case of Windows PC, install cygwin (cygwin.com) if it still has not. - Install sqlite3 if the PC still has not (tested version sqlite3 3.19.3). - Install gcc-g++ if the PC still has not. - Install python2 or python3 if the PC still has not (tested python versions 2.7.13 and python 3.6.1). - Install python2-devel or python3-devel, according to the version installed at the step before, if the PC still has not. - Install python2-pip or python3-pip, according to the version installed at the step before, if the PC still has not. - Install the pycrypto python module if python platform still has not (https://pypi.python.org/pypi/pycrypto). The easy way (pip2 or pip 3, depending on what you have): $ pip3 install pycrypto - Install the pycryptodome python module if python platform still has not (https://pypi.python.org/pypi/pycryptodome). The easy way (pip2 or pip 3, depending on what you have): $ pip3 install pycryptodome - Install xdd (or Vi IMproved) if the PC still has not. - Download & extract the latest version from http://n0.ms/wos , or following the download link at https://wos.peremolto.net/whatsapp-organizer-script.tar.gz - Change the current directory to the obtained package, then duplicate this file ./etc/whatsapp-organizer.cfg.example as ./etc/whatsapp-organizer.cfg , and edit the new file as per your needs: Fullpaths for databases directory, key file, sources, destinations... - Ensure that every necessary file is found in the path specified at the previous step. At the ./usr directory there are some predefined source directories based on some flavour of Whatsapp structure. But you can set your own way, or even combine several of them (one per line) because the script accepts more than one media source directory (see ./etc/whatsapp-organizer.cfg.example). Destination folder has to be unique (by default ./usr/destination) but it is customizable as well. The .cfg file also specifies which name patterns would be tried to match. As in the case before, you can set one per line as many patterns as you want. Execute: -------- - From the bash command line interface at the computer, go to the base directory and run the following command: $ ./whatsapp-organizer.sh - A logfile will be created, and its fullpath will be shown. While the process is running, you can monitor it in detail from a new console window, launching a "tail -f" of that logfile. - After a while (depending on the volume of information) the process will end up, and you will face a DESTINATION_MEDIA_DIR (set at ./etc/whatsapp-organizer.cfg) with one subdirectory per conversation interlocutor (named as the internal contact/group ID), and their related media files inside everyone of them. Whilest wa.db is accesible, every folder is also softlinked with a more friendly display name of the contact/group. Credits: -------- - Using a versioned (./bin/versioned-decrypt12.py) based on (./bin/original-decrypt12.py) taken from https://github.com/EliteAndroidApps/WhatsApp-Crypt12-Decrypter/blob/master/decrypt12.py - Thanks a lot to Matheus Coelho (@KaMyKaSii at http://forum.xda-developers.com) for providing testing and feedback under Termux for Android. Contact: -------- Pere Moltó Agut email: pmolto68 at hotmail dot com twitter: @peremolto website: https://peremolto.net