How to Open a File of a Specific File Type?

I want to open all .tff that are inside folders that are added to my download folder.

image

Is there anything i can write instead of ????? to achive this, or must i use a different approach?

Hi and welcome,

Sounds like you should instead use a Folder trigger, and a From each action.

To better help you, can you share your macro and a screenshot?

Thanks.

My bad, i have updated the post with a screenshot now :slight_smile:

My conclusion is that this won't work cuz wildcards dosent exist for open file command :frowning:

Correct. Keyboard Maestro's Open command does NOT support wild cards.

But you can do this any old time with the Execute a Shell Script action.

image

-Chris

I should have mentioned that %TriggerValue% doesn't work in the Execute a Shell Script action.

You have to save it to a variable and then reference the variable in the shell script.

See: Execute a Shell Script action on the KM Wiki.

-Chris

Thanks for the help, Chris!

I tried with shell script but it is really overwhelming and i didn't seem to get it to work.

My code was:

open –a BBEdit ~/Downloads/$KMVAR_trigger/fonts/*.ttf

But it didnt seem to work.

I tried a different approach by moving all contents of %TriggerValue% to the ~/Downloads, which I then could trigger to open when added to ~/Downloads. But I'm having issues getting all the contents out of the %TriggerValue% folder.

The macro I use:

Skjermbilde 2021-06-13 kl. 21.00.20

Issue:

Skjermbilde 2021-06-13 kl. 21.03.04

The file I'm moving contents from is the highlighted one. All the files above has been successfully moved from it. But the folder "fonts" won't be moved for it for some reason.

Any idea why?

I think you're misunderstanding how the trigger-value works for a folder-trigger.

It gets the whole path of the item added.

You didn't mention that the added folder might have sub-folders either.

The devil is in the details...

Here's an example of how to get all .txt files (you can change this) recursively in the newly added folder.

Folder Watcher Example ⇢ Display Text Files in A Folder Moved to ~-Downloads v1.00.kmmacros (10 KB)

Keyboard Maestro Export

Here's a test folder to copy to the ~/Downloads folder:

Test_Folder_To_Copy.zip (6.9 KB)

If you haven't read this it's worth a couple of minutes of your time.

Tip: How Do I Get The Best Answer in the Shortest Time?

-Chris

2 Likes

Thanks a lot, Chris. This really helped.

Sorry for not constructing my issue clearly. I'll try to do better next time!

1 Like