I experience looping in macro using trigger This folder xxx adds an item ignore partial or changing file in case of Duplicate File Action.
What is the best reliable way to avoid such looping?
Thanks for any hints/solution,
–Alain
I experience looping in macro using trigger This folder xxx adds an item ignore partial or changing file in case of Duplicate File Action.
What is the best reliable way to avoid such looping?
Thanks for any hints/solution,
–Alain
If you duplicate a file in a folder you are monitoring then clearly the new file will trigger the macro.
You cannot avoid the macro triggering (except perhaps by disabling the macro, but that would be problematic since you don’t know how long the duplicate might take and then there is a period of time afterwards while Keyboard Maestro waits to see that the file has sopped changing).
You will need to adjust your macro to ensure it does nothing with the duplicated file, probably by looking at the file name and seeing if it is a duplicated file, or perhaps keeping track of files to ignore or something like that.
But even worst trigger occurs when I simply rename a file in the monitored folder (using Path Finder outside of KM) which is not actually an real addition…
Is there a kind of file UID for a reliable filtering management inside the triggered macro?
I mean a lighter/smarter solution than MD5 computation
–Alain
Renaming a file is (as far as Keyboard Maestro’s Folder Contents trigger is concerned) the same as deleting and creating the file.
I believe file’s have some sort of uid on HFS, but Keyboard Maestro has no way to get it, and I’m not even sure whether all file systems would have it, but presumably you are only interested in HFS. Some sort of JXA might be able to extract the uid. But I have no idea how you would go about doing that.
Alternatively, you could try to recognize the file based on the extension and file size and maybe an md5 of the file.
As for the trigger Folder you propose a choice:
hopefully at least there is a technical way to distinguish between adds / removes.
What about overwrites (which don't trigger at present)?
As adds (may) induce some misunderstanding why not change naming to more accurate adds or renames?
The solution seems to used inode invariant in renaming:
--Alain