applescript

Applescript - creating a folder if it doesn't exist

与世无争的帅哥 提交于 2019-12-11 04:01:24
问题 Can someone please point out why this bit of Applescript isn't working? Thanks! on open droppedItems tell application "Finder" set inputFolder to (container of first item of droppedItems) as Unicode text if (exists folder ("converted") of inputFolder) then set outputFolder to (inputFolder & "/converted/") as text else make new folder at inputFolder with properties {name:"converted"} set outputFolder to the result as text end if end tell end 回答1: Here is another approach: mkdir -p will create

Applescripting - down arrow to highlight and select file within a Photoshop CS5 choose file window

微笑、不失礼 提交于 2019-12-11 02:55:02
问题 Hello and Thank you for any help whatsoever, I am writing a script to write a long list of file formats by accessing Adobe action scripts. My problem is that I cannot seem to access a file with a down arrow within the script once it is in a photoshop "choose file" window. I would have it open a specific file by path but this file name will change constantly. Here is what I have tell application "Adobe Illustrator" do script "eps format save" from "Default Actions" without dialogs end tell

Java starting running command in new terminal (mac osx) - process builder not running osascript properly

穿精又带淫゛_ 提交于 2019-12-11 02:22:22
问题 I'm trying to create a new process in a new window. I'm following this example for the command Running a command in a new Mac OS X Terminal window (using Java Process builder). I printed out the resulting command and it works if I type it in manually, but it doesn't start the new window when I run it. Something as simple as osascript -e 'tell application "Terminal" to do script "java -jar test.jar"' doesn't bring anything up Sample code: try { ProcessBuilder pb = new ProcessBuilder("osascript

Applescript and “starts with” operator

China☆狼群 提交于 2019-12-11 02:10:01
问题 Is there a way to check (in applescript) if a list (or block of html text) starts with any number of values. Example (checking for a single value) if {foobar starts with "<p>"} then -- do something awesome here end if except i would like to pass multiple values to check <p> or <h1> or <em> . Thanks in advance. 回答1: on startswith(txt, l) repeat with v in l if txt starts with v then return true end repeat false end startswith startswith("abc", {"a", "d", "e"}) -- true 回答2: If you want to stay

Why does Applescript run in Script Editor, but error when saved as Application?

喜欢而已 提交于 2019-12-11 01:58:54
问题 My applescript needs to detect its own filename, and the following runs fine on Snow Leopard (10.6) set my_name to name of me as string display dialog "Name: " & my_name It displays "Name: AppleScript Editor" when I run it from AppleScript Editor, and it displays "Name: NewTest" when I save it as an application called NewTest. When I run it on a Leopare (10.5) machine, it complains "Can't make name of <> into type string." When I remove the "as string" portion, it runs under Script Editor,

AppleScript: set Microsoft Excel cell's background color

此生再无相见时 提交于 2019-12-11 01:56:31
问题 Using AppleScript, how can I change the background color of "cells ranging from A3 to E3" to light grey? I still want the font to be in black. 回答1: Two caveats with this answer: You didn't specify which version of Excel, and the following was tested in v2004. tell application "Microsoft Excel" set theRange to range "A3:E3" set interiorObject to interior object of theRange set color index of interiorObject to 5 -- '5' is only a dummy value; change as needed. end tell Per the dictionary, color

applescript to render nuke script in terminal

﹥>﹥吖頭↗ 提交于 2019-12-11 01:47:47
问题 I want to be able to drop a Nuke script on to an Applescript application and then for the Nuke script to start rendering in a terminal. The script needs to get the file path of the dropped item, paste that in to a terminal window along with 'nuke -xi ' and then hit return. So far I have.. on open dropped_item get the POSIX path of dropped_item and... tell application "Terminal" if not (exists window 1) then reopen activate end tell Any ideas would be greatly appreciated. 回答1: This shouldn't

Applescript to ping test each client prior to ssh connection

自古美人都是妖i 提交于 2019-12-11 01:26:45
问题 I'm trying to make an Applescript that connects to a list local ssh machines, with each connection opening in a new terminal window. Prior to attempting the ssh connection, I'd like to ping the client to see if it's available: if it is, run the ssh command, if not then iterates to the next client. When I run the script it seems to work for the first connection but then gives me --> error number -10004 for the remaining clients (and hangs the debugger). Any feedback would be greatly

Detect Safari Private Browsing in AppleScript

二次信任 提交于 2019-12-10 23:27:11
问题 I'm trying to write AppleScript which would tell whether a window of Safari is in private mode . Here is the AppleScript to do so in Chrome: tell application "Google Chrome" set incognitoIsRunning to the (count of (get every window whose mode is "incognito")) is greater than 0 end tell if (incognitoIsRunning) then return "-- PRIVATE MODE --" end tell The old solution to see whether private browsing menu option is checked no longer works. 回答1: There is a quirk in Safari that can be exploited

Automator or Applescript, detect a new file in folder

≡放荡痞女 提交于 2019-12-10 23:05:33
问题 I am trying to write something that will detect a new file in a certain specified directory. I preferably would like this script to continue running indefinitely, and whenever I see a new file, I can copy it and move it somewhere else. I know this has to be possible, because dropbox does it, but I just do not know how to get this working or where to start. Any ideas? 回答1: What you're looking for (to spawn off Applescripts when adding new files into a "hot folder") is called "Folder Actions",