Hi all. I'd like to use an 'If Then Else' action to determine if a folder is empty or not before proceeding with a macro. What would be the best way of achieving this?
I've tried several different options with the 'At this path:' condition trying various combinations but I can't seem to get it to work. When I add files to this folder the state doesn't change from currently false to currently true so I'm a bit confused. Any help or advice would be much appreciated.
The "something exists" test is testing that a file or folder exists at the specified path (ie /Users/wseries/Downloads). If that was ~/Downloads, then something should exist, namely the Downloads folder. The fact that it doesn't leads me to wonder if your home directory is actually /Users/wseries…?
In any event, the condition will not tell you if the folder is empty or not. You can count the files in a folder like this:
I tried the same thing using a literal directory named (dragged from the Desktop) and got the same warning you did (which doesn't really matter in this case) and the same failure to count (which does). But using gglick's variable for a selected folder did work.
Update: I had my Display Text action inside the loop that counted. When I moved it outside to report even if there was nothing to count, it did indeed count. Sorry for the confusion.
The warning is letting you know that the index variable Path is never used in the For Each, which is usually an error. In this case, you really don't care about the path of the items, you just want to know how many times the loop runs, so it is fine.
You can remove the warning by referencing Path - even just in a comment. Like this:
Since the warning is just advisory, the check is deliberately very weak.