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
File details
Details for the file shotfirst-0.12.3.tar.gz
.
File metadata
- Download URL: shotfirst-0.12.3.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.14 Linux/5.4.109+
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fafdd0e00841df2dece5eb34c8ff8a7ed68143741f0bf3851f2fee0d0ff3b6a |
|
MD5 | 318b470f3664caee09dfe2c31f20fc74 |
|
BLAKE2b-256 | a0a2c41fc9cc40f0b25c5984566f5d51ef1cea47357e518cc4613c9e482eb169 |
File details
Details for the file shotfirst-0.12.3-py3-none-any.whl
.
File metadata
- Download URL: shotfirst-0.12.3-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.14 Linux/5.4.109+
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8817f0d14b65f7c5b15f2a82ac143c13c62e7a9e9d9d4572efa30fa11b498e4 |
|
MD5 | 3c027b1f9c30f28af3540435ee0a27e3 |
|
BLAKE2b-256 | d00203a692af197234db54c2fd9f7bef5c9cce0dd378523cf455a31f93e4f664 |