Skip to main content

Safely move photos and videos

Project description

Safely move photos and videos from a source directory with arbitrary files to photo and video destination directories. The media type of the file is used to determine if it’s a photo or video. Any other media types are ignored.

The date and time the photo or video was taken is detected (if possible). If it is a photo, the EXIF DateTimeOriginal tag is used if present. Else for photos or videos, the date taken is inferred from the file name since most media files are named by date taken. Finally, the modify time of the file is used as a best guess. The destination files are organized by year and given a consistent file name based on the detected date taken. If a destination file with the same date taken and different checksum exists, an incrementing suffix is appended to the file name.

You can optionally remove photos and videos from the source directory that are older than a provided number of days. Files are only removed if the media file is copied and matching checksum is verified or if the media file with matching checksum already exists in the destination.

You can skip files that were recently modified within a provided number of minutes.

My Use Case

I run this on my Dropbox camera uploads every night to:
  1. Free up space on Dropbox

  2. Point Plex at split up photos and videos directories

  3. Backup the organized photos and videos

Here’s the crontab:

# move dropbox camera uploads out of dropbox into media folders
0 2 * * * mvmedia Dropbox/Camera\ Uploads --photos=Media/Pictures --videos=Media/Videos --remove=30 --recent=30 --verbose >> /var/log/dropbox/mvmedia.log

Usage

Help:

usage: mvmedia [-h] --photos PHOTOS --videos VIDEOS [--remove REMOVE]
                  [--recent RECENT] [--verbose]
                  source

Move and rename photos and videos

positional arguments:
  source           Source folder to read media from

optional arguments:
  -h, --help       show this help message and exit
  --photos PHOTOS  Destination folder to move photos to
  --videos VIDEOS  Destination folder to move videos to
  --remove REMOVE  Remove files older than provided days
  --recent RECENT  Skip files recently modified within the provided minutes
  --verbose        Print verbose output

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mvmedia-1.0.1.tar.gz (5.2 kB view hashes)

Uploaded Source

Built Distribution

mvmedia-1.0.1-py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page