1

I'm trying to do the following:

on cleanup(x)
   tell application "Finder"    
      clean up window 1 by x
   end tell
end cleanup

cleanup("name")

However since x variable is a string, the clean up command doesn't accept it and exits with error. Is there a way to convert the string to something that the commands accepts or some other solution to unquote the variable without using if, else statements like this:

on cleanup(x)
   tell application "Finder"
      if x is "name" then
          clean up window 1 by name
      end if
   end tell
end cleanup

cleanup("name")
0

1 Answer 1

2

This should work.

    on cleanup(x)

    run script "tell application \"Finder\" to  clean up window 1 by " & space & x



end cleanup

cleanup("name")

From the StandardAdditions Library

run script v : Run a specified script or script file

  • run script script : the script text (or an alias or file reference to a script file) to run

    • [with parameters list of any] : a list of parameters

    • [in text] : the scripting component to use; default is the current scripting component

→ any : the result of running the script

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.