Automator and Variables in AppleScript

Hello


Try trying to get automator to add a variable to my AppleScript that sends a text message out, but cant seam to get it into the "quote" of the message section?


also i want to change the name of the Variable after using the "set value of Variable" as the file name comes back as the full directory and i only what that files name


for example on this one i get "/Users/Computer name/movies/file"


Here is my workflow so far hoping people can help

User uploaded file

iMac, macOS Mojave (10.14)

Posted on Sep 29, 2018 11:14 PM

Reply
Question marked as Top-ranking reply

Posted on Oct 1, 2018 1:19 AM

It would help to describe exactly what you have tried so far in order for anyone to determine what you mean by "can't seem to", but it is up to you to define whatever variable(s) you want to use. To replace the "Test Notification" text, your script would look something like:


on run {input, parameters}
  tell application "Finder" to set theName to name of first item of input
  tell application "Messages"
    set iMessageService to first service whose service type is iMessage
    set iMessageBuddy to buddy "whoever" of iMessageService
    send theName to iMessageBuddy
  end tell
end run

Similar questions

8 replies
Question marked as Top-ranking reply

Oct 1, 2018 1:19 AM in response to Braddyford

It would help to describe exactly what you have tried so far in order for anyone to determine what you mean by "can't seem to", but it is up to you to define whatever variable(s) you want to use. To replace the "Test Notification" text, your script would look something like:


on run {input, parameters}
  tell application "Finder" to set theName to name of first item of input
  tell application "Messages"
    set iMessageService to first service whose service type is iMessage
    set iMessageBuddy to buddy "whoever" of iMessageService
    send theName to iMessageBuddy
  end tell
end run

Sep 30, 2018 9:39 AM in response to Braddyford

The input parameter of the Run AppleScript action will contain the items sent from the previous action, so you can use something like first item of input or loop though all the items, for example


    repeat with anItem in input
      # tell application "Finder" to set fileName to name of anItem
    end repeat


Normally you would need to add an action to get file names, but since you are using an AppleScript action you can just use the Finder to get them.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Automator and Variables in AppleScript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.