This Python script organizes files within a specified directory based on their metadata. It primarily focuses on images and videos, sorting them into directories named after the camera model and renaming them with timestamps derived from their metadata.
- Organizes Files: Moves files into directories named after the camera model.
- Renames Files: Names files using a timestamp derived from their metadata
Example
Y{YEAR}-M{MONTH}-D{DAY}_h{HOUR}-m{MINUTE}-s{SECOND}_IMG
- Logging: Creates logs of operations and errors.
- Supports Various Metadata: Uses EXIF, file creation dates, and ffprobe data for file organization.
The script requires several dependencies and external tools:
- Python 3.9
- macOS
- External tools:
exiftool,mdls,ffprobe
Run install_deps.sh script to install the required Python libraries and tools.
Make sure you have the following tools installed on your system:
- exiftool: Available via package managers like
brewon macOS orapton Linux. - mdls: Part of macOS. Ensure you are running this on macOS.
- ffprobe: Part of the
ffmpegsuite, available via package managers.
-
Clone this repository or download the script.
git clone <repository_url> cd <repository_directory>
-
Perform install_deps.sh
./install_deps.sh
-
Modify the
media_dirvariable in the script to point to the directory containing the files you want to organize. -
Run the script using:
python3 excommunicado_refactor.py
- media_dir: Set this variable in the script to the directory where your files are located and you want to refactor the structure.
Logs are stored in logs_excommunicado/*.log directory with a timestamped filename.
Initial workspace:
/path/to/media_dir
β
βββ IMG_1234.jpg
βββ IMG_5678.heif
βββ IMG_xyz.jpg
βββ photo_123.jpg
βββ video.mp4After performing the script:
/path/to/media_dir
β
βββ iPhone 16 Pro
β βββ IMG_1234.jpg
β βββ IMG_5678.heif
β βββ video.mp4
β
βββ NIKON
β βββ photo_123.jpg
β
βββ Unknown Device
βββ IMG_xyz.jpg