There are several problems in your script. For one, you should access array elements with ${array[1]}
and not $(array[1])
. I did a few modifications, and this seems to work on my system:
#!/bin/bash
inotifywait -mr -e create files |
while read -r path eventlist eventfile
do
[[ $eventlist == *ISDIR* ]] && continue;
folder=$(basename "$path")
zip -j "$folder.zip" "$path/$eventfile"
done