The Multimedia Organizer Tool is designed to streamline and automate the organization of multimedia files within a specified folder. This powerful utility processes all files in a given source directory, identifies their modification dates, and systematically sorts them into subfolders within a designated destination directory. Each subfolder is named according to the date format YYYY-MM-DD, corresponding to the modification date of the files it contains.
This tool ensures that all media files are neatly organized by date, making it easier to manage and locate them.
- Automatic Sorting: Efficiently processes and sorts multimedia files by their modification date.
- Date-Based Folders: Creates subfolders in the destination directory named after the modification date in YYYY-MM-DD format.
- Comprehensive File Support: Supports a wide range of multimedia files, including images, videos, and audio files.
- User-Friendly: Simple and easy to use, with minimal setup required.
-
Prepare your directories:
- Ensure you have a source directory containing your multimedia files.
- Create or specify a destination directory where the organized files will be stored.
-
Run the tool:
python organize_media.py --source /path/to/source/directory --destination /path/to/destination/directory
Replace
/path/to/source/directory
with the path to your source directory and/path/to/destination/directory
with the path to your destination directory. -
Example command:
python organize_media.py --source /home/user/photos --destination /home/user/organized_photos
This command will process all multimedia files in
/home/user/photos
, identify their modification dates, and organize them into date-based subfolders in/home/user/organized_photos
.
Given the source directory
~/Desktop/test tree ok | 15:53:04
.
├── Església St Pere de Rubí 150301_2014.JPG
├── a_file.txt
└── document.doc
Run the multimedia tool organizer command
python reorganize.py --source ~/Desktop/test/ --destination ~/Desktop/output/
[+] Start Processing
|- Searching files... OK
------------------------
Files Report
------------------------
Extensions to be processed : ('.gif', '.png', '.jpg', '.jpeg', '.mov', '.mp4')
Files found : 1 / 3
Missing files : 2 / 3
Missed files have the following extensions: {'.doc', '.txt'}
Do you want to continue? yes/no > yes
[+] Reading files
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 35.23files/s]
[+] Creating directories
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 2126.93directory/s]
[+] Copying files
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 158.72file/s]
[+] All files were moved successfully!
Output directory result
~/Desktop/output tree ok | 15:47:55
.
└── 2024-06-14
└── stylus1
└── església st pere de rubí 150301_2014.jpg
To get a local copy up and running follow these simple example steps.
Install the project dependencies
pyenv virtualenv 3.12.1 image
pyenv local image
pip install -r requirements.txt
To be sure that everything is working as expected you can run the tests
pytest ok | image 3.8.6 py | 15:40:20
========================================================================= test session starts =========================================================================
platform darwin -- Python 3.12.1, pytest-8.2.2, pluggy-1.5.0
rootdir: /Users/eballo/Documents/work/python/file-organizer
collected 9 items
tests/test_organizer.py ..... [ 55%]
tests/test_process.py .... [100%]
========================================================================== 9 passed in 0.21s ==========================================================================
Please run pre-commit install
just once to install the git hooks that allow to preform some checks before commiting.
That will save us resources and time
The pre-commit checks that we run are:
- flake8
- utf-8 encoding
- correct JSON files
From inside the test directory
$image-organizer/tests/python -m pytest tests