Closed ctrngk closed 7 years ago
I have figured it out. The reason why solution 3 execute two times, is that touch aa
aa
added to directory, detected, and rename to aa.ok
. aa
deleted, also detected, and rename to aa.ok
, which raise error.Although solution 3 still works, the log file is not pretty. So the question change to: Could I differentiate add, delete, and modified method?
fswatch -x path
will solve this problem. Case closed.
Hi,
I want to append
.ok
after every new file found in test directory.➜ test
fswatch -0 . | xargs -0 -I {} mv {} {}.ok
mv: /Users/mac/test/cc: No such file or directory mv: /Users/mac/test/cc.ok: No such file or directory mv: /Users/mac/test/cc.ok.ok: No such file or directory mv: /Users/mac/test/cc.ok.ok.ok: No such file or directory mv: /Users/mac/test/cc.ok.ok.ok.ok: No such file or directoryAfter
touch cc
, It makes sense becausefswatch
detects newcc
, and renames it ascc.ok
, detects this new file and continues to rename ascc.ok.ok
, to endless journey.Possible solution 2: ➜ test
fswatch -0 -e '\.ok$' -1 . | xargs -0 -I {} mv {} {}.ok
This works, but the limitation-1
option might not be useful for background long-run task.Possible solution 3: ➜ test
fswatch -0 -e '\.ok$' . | xargs -0 -I {} mv {} {}.ok
mv: /Users/mac/test/aa: No such file or directory The wired issue: Aftertouch aa
, It executed two times, instead of one, for each new file. I did not know why.Any possible solutions to get around this? Please advise. Thank you.
Regards,