Mac OS app based on Applescript

*爱你&永不变心* 提交于 2019-12-25 18:32:16

问题


I'm new to Xcode as well as I am to AppleScript

All I need is to run an AppleScript in an Xcode application.

Bassically, the application is downloading pictures from a url list in Excel and renames the files acording the list in Excel

Here is the applescript code :

tell application "Microsoft Excel"
  set filenames to value of every cell of range "K3:K200" of sheet "Image_Moves" of document 1
  set URLs to value of every cell of range "L3:L200" of sheet "Image_Moves" of document 1
end tell

repeat with i from 1 to count URLs
  if (item i of filenames is not missing value) and (item i of URLs is not missing value) then
    set thisFname to quoted form of (POSIX path of ({path to desktop, "Image_Moves:"} as text) & item i of filenames)
    set thisUrl to quoted form of item i of URLs
    set status to (do shell script "curl -s -o " & thisFname & space & thisUrl)
  end if
end repeat

try
  tell application "Finder"
    delete (every item of folder ("Image_Moves") whose name begins with "0")
  end tell
on error
  display dialog ("Error. Couldn't Move the File") buttons {"OK"}
end try

回答1:


In Xcode, you can write a full application in AppleScript with the "Cocoa-AppleScript" template. Also, you can compile and execute an AppleScript with the NSAppleScript class. If your question is just about making an AppleScript executable, use Save As... in Script Editor and save your AppleScript as an application.

HTH



来源:https://stackoverflow.com/questions/38654871/mac-os-app-based-on-applescript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!