Any Ideas Why File Exists is Not Working?

I am trying to test if a file exists. Here is a screen shot of the actual file in Finder:

Here is my KM Test:

I even tried copying and pasting in the name to be sure I have it there correctly. I can't figure out why it is saying the file doesn't exist. Any ideas?

Thanks,

The same question was asked in this forum previously and one responder offered this as a solution:
kmImg20160319075356

The only relevant difference to your attempt is the “something exists” clause in the If action.

Perhaps try that and see if it makes a difference?

I saw that and tried that. It didn't help.

I even tried creating a file in Documents called aaJunk.txt in case the path was an issue:

Still didn't work:

I even tried typing in the whole path several ways:

Sorry that didn’t help. BTW the full path doesn’t require the MacintoshHD part, “/Users/...” is sufficient.

It must be something blindingly obvious but I’m away from my Mac right now so perhaps someone else will pop up with the solution. :confused:

Hey Stuart,

First of all – don't trust what the action says – test it – and make darn sure both your macro and macro group are active. (I should have put a otherwise action in my macro below to play a different sound if the file was not found.)

This works perfectly for me on my macOS 10.12.6 Sierra system:

File Exists Test v1.00.kmmacros (2.2 KB)

  • What version of macOS are you running?

  • Is the Keyboard Maestro Engine running?

    • If not then the display in the Keyboard Maestro Editor is affected and macros won't run.
  • How exactly are you getting the path to the file on your system?

    • The safest way is to drag and drop it into the Keyboard Maestro action.
    • Make SURE you haven't accidentally included any extra spaces, non-breaking-spaces, or linefeeds in the file-path field.
      • Copy the path to BBEdit or another text editor that can display invisible characters and take a look.

-Chris


Now then – I'm going to put on my Moderator's hat for a minute:

  • Please do not post giant screenshots to the forum that have meaningless empty space in them or are wider than necessary.

    • I have edited the major offender for you this time.
  • If you haven't read these they're worth a couple of minutes of your time.

  • Using the Keyboard Maestro Editor's Share to Forum function uploads an image of the selected item in the editor (the complete macro or the selected actions) and the associated macro/action file.

  • Copy As Image works nicely in the editor as well and produces better copy than screenshots.

⠀⠀⠀⠀⠀⠀⠀image

  • Please post complete macros if at all possible, because it's not fair to ask anyone to debug your work by eye and not give them an opportunity to test it directly.

1 Like

Hi @ccstone, I recall now that this came up as an issue not that long ago. It almost calls for something like a refresh button image next to what’s displayed, rather than have to try/test the action.

1 Like

Thanks for all the replies. I didn't know I could drag the file into the window, so I tried that. For this test I put it into my Downloads folder just to try someplace else with a short path with no spaces in the name. Below is a screen shot of what KM put in when I dragged it from Finder:

As you can see I even created a new test macro to test it. I also tried running it and "trying" it and neither worked.

Since I don't want to do a useless upload trust me that I also tried changing "something exists" to "a file exists" and both ran it and "tried" it again with the same results.

I am on KM 8.2.4.

I haven't upgraded from that as this is doing everything I want (up until now. :-))

Stuart

Can't reproduce, I get True:

image

BTW, just to show you it is calculating, I changed it to a file does not exist and it instantly turns to true. So it is certainly evaluating it. And, as I said, this was with me dragging the file from Finder into the file's path field. So I can repeat it with different files in different macros with different test conditions.

@Stuart, I can confirm, like the above posters, that this KM Condition does work as advertised. The fact that you are observing a different behavior suggests it is something specific to your Mac.

BTW, have you actually run the Macros you showed?

So, you need to do basic troubleshooting. See Troubleshooting -- KM Wiki.

Is your Documents folder stored in iCloud? If so, it is likely that the system is lying to you about where the file really is, and not keeping its lies straight when talking to Keyboard Maestro.

In the Terminal, try the command:

ls ~/Documents

and if that looks like; try:

ls ~/'Documents/Winter … Bill.pdf'

(copying the path from Keyboard Maestro, and enclosing it in quotes as shown (do not include the ~/ at the start in quotes or it will not work).

Hey Stuart,

Please ==always== advise us if/when you're using a version of Keyboard Maestro that is not the most current.

What version of macOS are you using? (I asked before.)

See this macro to make it easy to insert KM and macOS version info:

Paste Keyboard Maestro Version and macOS System Version

Personally I would never use an old version of Keyboard Maestro, unless I needed to for compatibility.

A) I want Peter to have upgrade money, so he can afford to keep developing Keyboard Maestro.

B) I want any and all improvements made to Keyboard Maestro.

If Peter's test above doesn't illuminate what's going on, I advise you to create a new user and install the Keyboard Maestro 9.2 Demo on it.

Run your test macro and see what happens.

-Chris

1 Like

Hey Stuart,

See what my macro returns for your problematic file path(s).

-Chris

Does Item Exist? 1.00.kmmacros (9.2 KB)