Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Setting up watch folder, watching for new files in folder

Featured Replies

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.

  • 3 months later...

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?

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.