Book Image

Raspberry Pi cookbook for Python programmers

Book Image

Raspberry Pi cookbook for Python programmers

Overview of this book

Table of Contents (18 chapters)
Raspberry Pi Cookbook for Python Programmers
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Organizing your photos automatically


Now that we have a class that allows us to gather information about photos, we can apply this information to perform useful tasks. In this case, we will use the file information to automatically organize a folder full of photos into a subset of folders based on the dates the photos were taken on. The following screenshot shows the output of the script:

The application will use the photo's information to sort pictures into folders by the date on which they were taken

Getting ready

You will need a selection of photos placed in a folder on the Raspberry Pi. Alternatively, you can insert a USB memory stick or card reader with photos on it—they will be located under /mnt/. However, please make sure you test the scripts with a copy of your photos first, just in case there are any problems.

How to do it…

Create the following script in filehandler.py to automatically organize your photos:

#!/usr/bin/python3
#filehandler.py
import os
import shutil
import photohandler...