[Synology Download Station] Run filebot command only if there are new files

Support for Synology NAS, QNAP NAS and other Embedded Linux systems
Post Reply
User avatar
rednoah
The Source
Posts: 23941
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

[Synology Download Station] Run filebot command only if there are new files

Post by rednoah »

e.g. find files in /volume1/complete that are less than 60 minutes old and larger than 100 megabytes:

Shell: Select all

find /volume1/complete -type f -size +100M -mmin -60 -print -quit
-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:

Shell: Select all

if find /volume1/complete -type f -size +100M -mmin -60 -print -quit | read
then
	filebot-node-task 0
fi
:!: 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.



:idea: 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.
:idea: Please read the FAQ and How to Request Help.
Post Reply