2016-09-15 14 views
0

我需要逐個打開一個充滿URL的文本文件,然後在移到下一個URL之前根據每個網頁執行操作。逐個導航到文本文件中的URL

問題Read a text file with Automator.app line by line有很大幫助,但檢查不起作用 - 第一個警報窗口顯示所有URL,而後續警報不顯示任何內容。我猜這個錯誤與本節有關:

linenum=${1:-0} 
filename="/etc/passwd" # full path of your text-filename 
let linenum++ 
sed -n "${linenum}p" < "$filename" | pbcopy 
echo $linenum 

另外我想複製的URL被粘貼到Safari的地址欄並在那裏導航。這可能嗎?

回答

0

我假設你的文本文件是由每行一個URL(=每段)組成的,它是一個'txt'文件。然後腳本波紋管所有幫助您:

set F to choose file "select your text file" 
set myURLs to paragraphs of (read F as text) 
repeat with aURL in myURLs 
    open location aURL -- open in your default browser (ie Safari) 
    -- do what ever you need to do, the URL is open 
end repeat 

這個腳本還假定在文本文件中所有的線是有效的URL。