cnrd Posted January 5, 2017 Share Posted January 5, 2017 Hi I'm trying to setup a watch folder that will run a command whenever I add a file to that folder over SMB, I got it somewhat working, but I still have some problems with timing (or multiple runs on the same file). The script is supposed to convert any mkv or avi file I add to the folder into an MP4 using Don Melton's transcode-video script (For which a docker container have already been created. The idea is, that I can just convert my DVDs to MKV files and dump them onto the server for automatic processing. This is what I currently have: inotifywait -m -r convert_movies -e close_write | while read path action file; do echo "The file '$file' appeared in directory '$path' via '$action'" if [[ $file =~ .*\.(mkv|avi) ]]; then #docker run --rm -it -v /mnt/user/Misc/convert_movies:/data ntodd/video-transcoding transcode-video --crop detect --mp4 "$(echo $path | sed 's/convert_movies\///g')$file" echo "File $file was written to $(echo $path | sed 's/convert_movies\///g')$file, converting..." fi done I commented out the docker run command, for testing that the script actually work. The problem is, that every time I add a file, I get multiple "close_write" triggers: The file 'test.mkv' appeared in directory 'convert_movies/test/' via 'CLOSE_WRITE,CLOSE' File test.mkv was written to test/test.mkv, converting... The file 'test.mkv' appeared in directory 'convert_movies/test/' via 'CLOSE_WRITE,CLOSE' File test.mkv was written to test/test.mkv, converting... I'm not really sure how to avoid this, or if there is something better than using inotifywait for the trigger, I would really appreciate if someone could help me getting this to work correctly. Quote Link to comment
TheClaus Posted April 25, 2017 Share Posted April 25, 2017 I was wondering if you figured this out and also how are you running this script? Is it through User Scripts plugin or just shell access? Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.