This Python script was created as a personal project to sort personal photographs based on their camera and Android models. It extracts metadata from files using ExifTool, identifies the camera and Android model of each file, and sorts them into different directories based on this information.
The script requires Python 3.6 or later. You can download Python from the official website. After installation, you can verify the Python version by running the following command in a terminal:
python --version
ExifTool is a platform-independent Perl library plus a command-line application for reading, writing, and editing meta information in a wide variety of files. You can download ExifTool from the official website. After installation, add ExifTool to your system's PATH.
colorama is a Python library for cross-platform colored terminal text. You can install colorama using pip, which is a package manager for Python.
pip install colorama
Before running the script, you need to configure it according to your requirements. Open the script in a text editor and modify the following variables:
source_dir
: The directory that the script will scan for files.camera_target_dir
: The subdirectory where the script will move files that match the specified camera model.phone_target_dir
: The subdirectory where the script will move files that match the specified Android phone model.camera_model
: The camera model that the script will look for.phone_model
: The Android phone model that the script will look for.
After configuring the script, you can run it with Python:
python photoExifSorter.py
- The script first ensures that the
camera_target_dir
andphone_target_dir
directories exist, creating them if necessary. - It then iterates over each file in the
source_dir
. - For each file, it uses ExifTool to extract the metadata. Specifically, it extracts the "Model" field (for the camera model) and the "AndroidModel" field (for the Android model).
- It compares these extracted values to the
camera_model
andphone_model
specified at the top of the script. - If the extracted camera model matches
camera_model
, it moves the file to thecamera_target_dir
directory. - If the extracted Android model matches
phone_model
, it moves the file to thephone_target_dir
directory. - If there's an error processing a file, it prints an error message and continues with the next file.
The script includes basic error handling. If there's an error while processing a file (for example, if the file can't be read, or if the metadata can't be extracted), the script will print an error message and continue with the next file. The error message includes the filename and a description of the error.
This project is licensed under the MIT License. See the LICENSE
file for more details.
This script was developed as a personal project for sorting personal photographs. It is provided as-is, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.