1

In the Filter Finder Items and Find Finder Items actions, Automator lets you type out criteria for what your looking for like:

Folder Name Contains: (Manually Insert Text Here)

Here is an example image of "AnchorFile" being the typed criteria:

Example Action

Is there anyway to pass a variable onto the filter?

I have tried to put a Get Value of Variable action before the filter/find in the hopes of being able to use the variable as the search criteria. Similar to this workflow:

Filter w/ Variable??

The goal is to find the "XXXXX_Workers Compensation" folder on my computer using only a variable and filter/find Actions

I hope this is clearer than a previous post I made as I am a newbie in the Applescript/Automator world.

If we can get this "pass a variable to filter/find" thing to work, it would effectively:

  • Create a foldername from a filename,
  • Then input that foldername into the search bar of Finder to bring up the folder in Finder.

Thanks for any help you can give.

4
  • RE: "I hope this is clearer than a previous post I made" -- Sorry to say, but no, it is not any clearer than the now deleted previous post Using Finder Items as filter criteria in Automator (Need 10,000 rep to see the contents of this link, or be the author.) Commented Mar 20, 2021 at 0:42
  • The text field in that action does not accept variables (not all of them do), so you will need to use something else.
    – red_menace
    Commented Mar 20, 2021 at 2:56
  • @user3439894 What could I have done to present the issue more clearly?
    – PotterFan
    Commented Mar 22, 2021 at 17:15
  • @red_menace you were right. I needed to switch out Filter/Find Finder Items for Spotlight I think increased functionality is needed to use variables as inputs in the criteria section of these actions.
    – PotterFan
    Commented Mar 22, 2021 at 17:18

1 Answer 1

-1

Turns out I needed to do a spotlight search instead of Filter/Find Finder Items in order to use a string to find the folder by its name alone (Without path).

I also did not need to store the filename as a variable in order for me to accomplish this final workflow but spotlight can use a variable that is a string to search I found out.

Here is my final workflow. WorkFlow

EXPLANATION:

(Get Specified Finder Items and Get Folder Contents were in place for testing within Automator)

  1. A file being added to a folder called "WCCalcs" triggers the workflow.

  2. Steps 1-2 (Filter Finder Items and Set Value or Variable):

    Singles out our new file which is a pdf and saves it in a variable called 'MovingFile'. It will always look like "#####_WCCalcs_YYYY"

    • with "#####" being a 5-digit number
    • and "YYYY" being the current year
  3. Steps 3-4 (Get PDF Metadata and Run AppleScript):

    Takes the first 5 characters of the file name and adds it to a string and this creates the folder name we need becoming "#####_Workers Compensation" (See AppleScript.)

  4. Steps 5-8 (Spotlight,Get Folder Contents, Filter Finder Items, Set Value of Variable):

    Uses the newly created folder name to do a spotlight search as well as filters down to a destination folder which we stored in a variable called 'Destination.

  5. Steps 9-10 (Get Value of Variable and Move Finder Items):

    Calls MovingFile variable and moves it to the Destination folder

Thanks for your help @red_menace it caused me to think outside of what I was trying to do.

2
  • While this answer may work for for you, nonetheless as presented it's of little to no value to anyone else because all but one of the actions are collapsed and we cannot tell how any of the remaining actions are configured. BTW If more then one file is received in the Folder Action then as coded Run AppleScript action it will fail. Commented Mar 22, 2021 at 22:18
  • @user3439894 only 1 file will arrive at a time so that should not be a problem for me. The main question that this answers is 'finding a directory without needing the entire file path' just the one unique directory. How can I modify the explanation to make it more useful to others? also i would've loved to work with you to modify your answer to make the workflow quicker.
    – PotterFan
    Commented Mar 22, 2021 at 22:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .