--exclude option only acts on filenames, there's no direct way to do it. You could try round-about ways like using
find to print the name of all directories:
inotifywait --exclude "echo -n (;$(find . -maxdepth 1 -mindepth 1 -type d -printf '%P|');echo )" .
Note that I didn't specify
-r, since that will cause newly created subdirectories to be watched too.
This might break with some special characters.
You could also try:
find . -maxdepth 1 -mindepth 1 -type d -printf '@%P\n' > list_of_directories
inotifywait --fromfile list_of_directories .
inotifywait will exclude any files or folders in
list_of_directories which begin with
@ (all of them do).
If you're using
inotifywait with the recursive option, let
find list all nested subdirectories as well by removing the
-maxdepth restriction (also applies to the first command):
find . -mindepth 1 -type d -printf '@%P\n' > list_of_directories
inotifywait --fromfile list_of_directories . -r
-mindepth is retained to prevent
find from matching
., and thus excluding the current directory as well.