2013-06-18 50 views
1

我在Applescript中创建了一个'从列表中选择',其中的选项是.txt文件中的行。它看起来像这样:applescript从列表结果中选择

set listofUrls to {} 
    set Urls to paragraphs of (read urlList) 
    repeat with nextLine in Urls 
     if length of nextLine is greater than 0 then 
      copy nextLine to the end of listofUrls 
     end if 
    end repeat 
    choose from list listofUrls with title "Refine URL list" with prompt "Please select the URLs that will comprise your corpus." with multiple selections allowed 

这个作品非常漂亮,如果我返回结果',我得到在正式的“网址X”结果窗口列表“urlb”等

的问题是看过那部当我尝试这个列表保存到一个文本,用,例如:

write result to newList 

文件的格式是奇怪:

列表utxtÇhttp://url1.htmlutxtÇhttp://url2.htmlutxt~http://url3.htmlutxtzhttp:// ...

似乎空字符已经插入了。那么,有人知道发生了什么吗?任何人都可以想办法:

a)写结果为干净(最好是换行符)txt? b)清理这个输出,使其恢复正常?

谢谢你的时间! 丹尼尔

+0

我可以看到你的文件写入代码,那是你遇到问题的地方 – mcgrailm

回答

0

没有看到你写的文件是什么,我认为你只需要结果转换为字符串与段落

伪代码

set listofUrls to {} 
set urlList to ":Users:loaner:Documents:urllist.txt" as alias 
set Urls to paragraphs of (read urlList) 
repeat with nextLine in Urls 
    if length of nextLine is greater than 0 then 
     copy nextLine to the end of listofUrls 
    end if 
end repeat 
choose from list listofUrls with title "Refine URL list" with prompt "Please select the URLs that will comprise your corpus." with multiple selections allowed 

set choices to the result 
set tid to AppleScript's text item delimiters 
set AppleScript's text item delimiters to return 
set list_2_string to choices as text 
set AppleScript's text item delimiters to tid 
log list_2_string 
write list_2_string to newList 
+0

是的!我想这是文本项目分隔符的问题。这绝对是一种享受!非常感谢,朋友。 – user2437842

+0

高兴地帮助:) – mcgrailm

+0

基本上你试图写清单到文件,它将分隔符转换成一些奇怪的东西:) – mcgrailm