Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Elpachato

macrumors newbie
Original poster
Dec 5, 2017
3
0
Hello,

This is the initial automator workflow i made for automated printing, i use hazel to watch folders and launch it :
1 - Get indicated finder items => folder(s) specified
2 - Get folder content
3 - Filter folder content => None of following conditions true : file extention is not jpg
4 - Dispense items incrementally
5 - Add date and time => actual time hr min sec before name
6 - Move finder items => folder specified
7 - Open finder items => photoshop dropplet specified
8 - Pause => time specified according to photoshop dropplet execution
9 - Loop => number of loops specified - results as entry

At step 7 i need to place a condition if or if according to name content :
if file name contains CODE1 than open in photoshop dropplet CODE1
if file name contains CODE2 than open in photoshop dropplet CODE2
and as many as needed if i have more variables

At this point my issue is with automator function "filter finder items" that works as if and if only

I am trying to solve this with applescript but i am a newbie

Here is what i tried in place of step 7 (of course not working)
- Execute applescript
Code:
tell application "Finder"

get "filename"

if "filename" contains "AAA" then

tell application "Finder"

open file using ":Users:ADMIN:Desktop:FOLDER:dropplet AAA.app"

end tell

else

if "filename" contains "BBB" then

tell application "Finder"

open file using ":Users:ADMIN:Desktop:FOLDER:dropplet BBB.app"

end tell

else


end if

end if

end tell

If anyone can tell me what i should try, thanks in advance
 
Perhaps this may get you going :

Run AppleScript action :

Code:
on run {input, parameters}
    (* Your script goes here *)
    tell application "Finder"
        -- insert actions here
        repeat with i from 1 to number of items in input
            set this_item to item i of input
            set fileName to name of this_item
            if fileName contains "Test" then
                open this_item
            end if
        end repeat
    end tell
    --return input
end run

Finder example :

Code:
tell application "Finder"
    open document file "TestFile.txt" of folder "Documents" of folder "stagiair" of folder "Users" of startup disk using application file "TextEdit.app" of folder "Applications" of startup disk
end tell
 
Last edited:
Hi,

Kryten's nudge in the right direction will be helpful, I'm sure.

Don't take this the wrong way, but it looks like you're just guessing at what commands and syntax might be. Hats off to you for having a go (seriously!), but that's really not the best way to learn. I suggest you check out the tutorial(s) here for some AppleScript basics:

https://macosxautomation.com/applescript/index.html

...and take a look at an application's scripting dictionary to get an idea of commands.

Feel free to ask any questions back here!

Good luck.
 
Thanks for the help it works !

Just added the else part with another if

I can also simply have as many script as i want in the workflow

both works same

but the second option allow to activate or deactivate within my automator workflow

Thanks a lot !

I am really looking into learning all of this better as i would love to make a true app out of this workflow

Thanks again and again, this will be a life changer
 
Last edited:
One question : did you take into consideration my automator workflow and how it actually works ?
To be honest, nope.
It doesn't work or you wouldn't be asking for help.

So with kryten's proposition, the problems i have are :

-can't have a repeat part because i already have an incremental action in automator workflow which makes that only one item is processed at one time, putting all my automator workflow in applescript would be a huge step for me, i would love to make a true app out of it but way out of my league for the moment
Input in the Run AppleScript action is a list. Even if it has only one item in it, it is stil a list.

-this item is already known in automator workflow and can't actually be specified by a name, because its name will change all the time

-the appS launched with the item need to be different appS according to different content in file's name within the script

Using this script maybe means i would have to make one script per condition for your proposition to work but still need to get rid of the repeat part and not specify item by name, just as an entry from the actual workflow

Do you understand what i mean ?
I'm not forcing you to do anything. I'm done here. Good luck.
 
  • Like
Reactions: superscape
To be honest, nope.
It doesn't work or you wouldn't be asking for help.


Input in the Run AppleScript action is a list. Even if it has only one item in it, it is stil a list.


I'm not forcing you to do anything. I'm done here. Good luck.
thanks again for you help, as you can see i have edited the post before you ended to answer, didn't mean to offend you, i understood the repeat part after checking on this link https://developer.apple.com/library...rConcepts/Articles/ImplementScriptAction.html

Just a last question, to make one "if" to check 2 or 3 different content in filename for same app launching, what should i put ?
 
Last edited:
thanks again for you help
Just a last question, to make one "if" to check 2 or 3 different content in filename for same app launching, what should i put ?
You're welcome. Don't know if I understand your last question but I think you've almost given the answer to it yourself. Let's write that out in pseudo-code.

Code:
if fileName contains "Linus" or fileName contains "Steve" or fileName contains "Bill" then
launch same app
end if
Info : Operators Reference - Apple Developer - Multiple Criteria for If statement in AppleScript
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.