如何阅读文件,并与Mac(的AppleScript)的读取结果打开Safari? [英] How to read a file and open Safari with the read result with Mac (AppleScript)?

查看:1339
本文介绍了如何阅读文件,并与Mac(的AppleScript)的读取结果打开Safari?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要根据读取结果打开多个Safari浏览器(或打开选项卡OK)。

I need to open multiple Safari (or open the tab is OK) based on the read result.

例如,如果一个文件具有

For example, if a file has


http://a.com
http://b.com

我想开a.com和b.com使用S​​afari。

I want to open a.com and b.com using Safari.

我怎么能做到这一点与Mac / AppleScript的?

How can I do that with Mac/AppleScript?

也许我可以运行Python称之为打开-a野生动物园http://a.com,但我猜的AppleScript是这种工作的工具。

Maybe I can run python calling "open -a Safari "http://a.com", but I guess AppleScript is the tool for this kind of job.

推荐答案

不知道蟒蛇,但这将读取一个文本文件,并打开窗户,让我看看,如果我能得到的标签为你虽然
     设置地点的第(读取(选择文件,提示选择包含URL文本文件))
      在位置艾琳重复
        如果艾琳的长度是大于0,那么
            告诉应用程序野生动物园
                使新的文件在文件末尾
                设置文件1网址阿利娜
            告诉结束
        万一
      结束重复

not sure about python but this will read a text file and open windows let me see if I can get tabs for you though set locations to paragraphs of (read (choose file with prompt "Pick text file containing urls")) repeat with aline in locations if length of aline is greater than 0 then tell application "Safari" make new document at end of documents set URL of document 1 to aline end tell end if end repeat

编辑:

确定这是更好,它会打开他们在一个窗口的标签页

Ok this is better and it opens them in tabs of a single window

  set locations to paragraphs of (read (choose file with prompt "Pick text file containing urls"))
  tell application "Safari"
    activate
    set adoc to make new document
  end tell
  repeat with aline in locations
    if length of aline is greater than 0 then
        tell application "Safari" to make new tab at end of window 1 with properties {URL:aline}
    end if
  end repeat

新Addtion

这是基于与我一起regulus6633的职位的另一种方式。

this is yet another way based on regulus6633's post in conjunction with mine

 set locations to paragraphs of (read (choose file with prompt "Pick text file containing urls"))
 repeat with aLocation in locations
    tell application "Safari" to open location aLocation
 end repeat

这篇关于如何阅读文件,并与Mac(的AppleScript)的读取结果打开Safari?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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