Monitor a number of directories for files and copy/move them
Project description
Overview
This is just a very simple inotify monitor for “dropbox” style folders. What it does is you give it a JSON config file and some directories and it will go and find all the files in the directories and execute shutil operations on them (by default copy2 which means the file is copied along with the metadata) to the configured location.
Installing
Option 1: Clone this repo and pip install . (bleeding edge)
Option 2: Run pip install shotfirst (released)
Configuration
With the following configuration file shotfirst.json:
{ "image/jpeg, image/gif, image/png": { "mask": "%Y/%m/%d", "target": "/tmp/foo/pics", "handler": "shotfirst.handlers.exif_image_handler" }, "video/webm": { "target": "/tmp/foo/videos", "operation": "move", "mask": "%Y/%m/%d", "handler": "shotfirst.handlers.video_handler" }, "application/pdf": { "target": "/tmp/foo/docs", "operation": "movereplace", "handler": "shotfirst.handlers.pdf_handler", "mask": "%Y/%m" } }
shotfirst shotfirst.json /tmp/inbox will:
Monitor the /tmp/inbox folder for files
Copy all GIF, JPEG, and PNG images found to a directory /tmp/foo/pics and use the EXIF metadata from the image to figure out the sub-folder structure (which is year/month/day)
Move all the WebM videos to a directory named /tmp/foo/videos based on the video metadata, if available. Otherwise will fall back to the file system meta data.
Copy all PDF files to a directory /tmp/foo/docs based on the PDF metadata if available. If the file was somehow imported previously, overwrite with the newly discovered file
Running in a container
There’s a published container image, to run you will have to mount your configuration file and your input and output folders, for example:
podman run --rm -it -v `pwd`/myconfig:/etc/shotfirst.json -v `pwd`/input:/inbox:rw -v `pwd`/output:/outbox:rw thekad/shotfirst:latest
And adjust your configuration appropriately to output the files to subdirectories under /outbox.
If you want to monitor multiple directories, you can mount them as volumes and then set the SDIRS environment variable, like this:
podman run --rm -it -v /opt/dropbox1:/inbox1 -v /opt/dropbox2:/inbox2 -e SDIRS="/inbox1 /inbox2" thekad/shotfirst:latest
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
Built Distribution
Hashes for shotfirst-0.12.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a5669c9a8181bb1313ce9cfa37806432782ab1b7f8160aecf0e9477bca2b847 |
|
MD5 | c5231e0234b4532cb2bd067fd2c2f366 |
|
BLAKE2b-256 | 98bf8975cd37a8d161ef1673bb28b346c1840bf11b7d8fe9ced9f208734c1051 |