[Synology Download Station] Run filebot command only if there are new files
Posted: 22 Jan 2023, 07:56
e.g. find files in /volume1/complete that are less than 60 minutes old and larger than 100 megabytes:
-type f ... find files
-size +100M ... find files larger than 100 megabytes
-mmin -60 ... find files less than 60 minutes old
-quit ... quit with at least 1 file has been found
e.g. bash script that will run filebot only if find found a recently modified large file:
Note that find returns with Exit Code 0 / TRUE regardless of whether or not any files have been found. We use | read to check if find has produced any output and return Exit Code 0 / TRUE or Exit Code 1 / FALSE to make our if-condition work correctly.
If you are using Synology Download Station and want to process newly completed files near real-time (as opposed to running filebot once a day at midnight which is recommended) then you can use the find command (because find is very fast and lightweight) to quickly check if a filebot call is in order. You can then have Synology Task Scheduler run your task every hour to check for new files, and call filebot only if and when needed.
Shell: Select all
find /volume1/complete -type f -size +100M -mmin -60 -print -quit
-size +100M ... find files larger than 100 megabytes
-mmin -60 ... find files less than 60 minutes old
-quit ... quit with at least 1 file has been found
e.g. bash script that will run filebot only if find found a recently modified large file:
Shell: Select all
if find /volume1/complete -type f -size +100M -mmin -60 -print -quit | read
then
filebot-node-task 0
fi

