2010-10-27 88 views
3

我从来没有搞砸AppleScript,所以这只是一个概念给我。这可以工作吗?AppleScript从HTTP服务器下载文件,改变URL?

Bungie,游戏设计师,将在系统命名的文件和目录中托管大量的Halo Reach PNG。 IE:同一个词的

http://www.bungie.net/images/reachstats/commendations/onyx/onyx_large_precision_multiplayer.png

更改两个实例,你生成图像的另一个版本。更改“缟玛瑙”到“铁”,“青铜”,“白银”或“黄金”,你会得到相应的图像,像这样:

http://www.bungie.net/images/reachstats/commendations/gold/gold_large_precision_multiplayer.png

会一个AppleScript能够利用输入URL,找到并更改URL中单词的实例,然后将关联的文件下载到目录中?今天是我的生日(十月二十七日!因此XXVII),如果这将起作用,如果有人能做到这一点,我会非常兴奋!

感谢您的所有答案!

+0

AppleScript是* so * last millenium。必须有更好的方法来做到这一点。我当然忘记了大约10年前我对AppleScript的所有知识,并且我不愿意回想起它...... – 2010-10-27 13:00:46

+0

由于您在Mac上,我可能会使用wget使用shell脚本来执行此操作。 – 2010-10-27 13:01:50

+0

那好吧! – Justin 2010-10-27 13:02:43

回答

1

这工作:

set the destination_file to ((path to desktop as string) & "picture.jpg") as file specification 
set thisImageSRC to "http://www.bungie.net/images/reachstats/commendations/gold/gold_large_precision_multiplayer.png" 
tell application "URL Access Scripting" 
    download thisImageSRC to destination_file replacing yes 
end tell 

字符串操作与改变的AppleScript的文本项分隔符完全做到。因此,要获得该URL的组件集成到一个列表,你需要做到以下几点:

set oldDelims to AppleScript's text item delimiters 
set AppleScript's text item delimiters to "/" 
set theUrlComponents to (every text item of theURL) as list 
set AppleScript's text item delimiters to oldDelims 

加入盐调味,但我第一个评论者,有更好的语言来做到这一点达成一致。 AppleScript是我最后的选择。

+0

AppleScript编辑器突出显示了第一行“文件规范”并给出了一条错误消息。我应该改变它到别的东西吗? – Justin 2010-10-28 21:21:11

+0

URL访问脚本只是'curl'命令的前端。您应该能够删除它并使其仍然有效。 – 2010-10-29 14:16:04