-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathmonitor.sh
More file actions
executable file
·40 lines (29 loc) · 767 Bytes
/
monitor.sh
File metadata and controls
executable file
·40 lines (29 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
if [ $# != 3 ]; then
echo "Usage: $0 <transform utility> <source dir> <target dir>" 1>&2
exit 1
fi
TRANSFORM="$1"
SRC="$2"
DST="$3"
if [ ! -d "$SRC" ]; then
echo "Source directory $SRC not found" 1>&2
exit 1
fi
if [ ! -d "$DST" ]; then
echo "Target directory $DST not found" 1>&2
exit 1
fi
cd $(dirname "$0") || exit 1
if [ ! -d .venv ]; then
echo "Virtual environment not found. Run 'uv sync --all-extras' first." 1>&2
exit 1
fi
. .venv/bin/activate
"$TRANSFORM" "$SRC" "$DST"
echo "Finished processing $SRC ($TRANSFORM)"
inotifywait -m -e CLOSE_WRITE,DELETE "$SRC"|while read dir event fname; do
echo "${dir}${fname} $event" 1>&2
echo "${dir}${fname}"
done | "$TRANSFORM" "-" "$DST"
# monitor.sh ends here