Hi Everyone,
I am having a problem trying to do a quick check to see if a file exists. In theory it should be quite easy but for some reason and after spending several hours trying to get it to work I am admitting defeat and posting here for help! I have searched this forum and also ChatGPT for help but am still not able to find my text file! I just need to check if a text file exists in a folder and if it does great, just carry on down, if it does not then inform me via message so I can add the file and continue down the pipeline. The print screen should be self explanatory as it's quite straight forward (in theory) but I am also attaching the offending macro. Note that the Job report file will have different names depending on the job so I cannot just search for Job Report.txt and therefore have to search for .txt instead.
I'm still reading it, but I can see one small error that COULD cause your problem. You have "The Variables" at the top of your macro. Remove that. Also, based on your problem description, I think you also remove "The Finder's Selection".
P.S. I think this problem can be solved without a loop at all. Not that it's "wrong" to use a loop, if you want to, but if a single IF statement can solve it, why not be simple?
I think this problem can be solved without a loop at all. Not that it's "wrong" to use a loop, if you want to, but if a single IF statement can solve it, why not be simple?
Quite honestly because i am not great a keyboard maestro and am learning, so yeah totally open to a new / better way of doing it as it's highly likely that I have just totally overcomplicated the whole thing!
Here's one way that seems to be working. There are probably dozens of alternate solutions. My way may not be the best way, and I hope someone improves on it.
Of course, you have to replace my path with your path. And then you can replace my Display actions with whatever code you want to insert.
Thank you very much for your help. Just cannot get this to work for some reason! I would have thought that this would be quite a simple thing to do but for some reason its not working, whichever way I try to solve it...
Did you enclose the Execute Shell Script action inside the "Try" action as my macro specifies? I don't think you did. Are you willing to upload your macro so I can verify that you copied my code?
Also, based on your error message, it seems you didn't include "*.txt" as my code indicated. Are you willing to upload your macro so that I can verify this?
Note that the Job report file will have different names depending on the job so I cannot just search for Job Report.txt and therefore have to search for .txt instead.