基于Applescript的Mac OS应用 [英] Mac OS app based on Applescript

查看:146
本文介绍了基于Applescript的Mac OS应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Xcode的新手,也是AppleScript的新手。

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

我所需要做的就是在Xcode应用程序中运行AppleScript。

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

基本上,应用程序是从Excel的URL列表中下载图片,并根据Excel中的列表重命名文件

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

这是applescript代码:

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


推荐答案

在Xcode中,您可以使用可可-AppleScript模板。另外,您可以使用NSAppleScript类编译并执行AppleScript。如果您的问题只是关于使AppleScript可执行文件,请在脚本编辑器中使用另存为...并将AppleScript保存为应用程序。

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

这篇关于基于Applescript的Mac OS应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆