我在Applescript中创建了一个“从列表中选择”,其中选项是.txt文件中的行。它看起来像这样:
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
这非常好用,如果我'返回结果',我会在结果窗口中的正式“urlx”,“urlb”等中获得一个列表。
当我尝试将此列表保存到文本文件时出现问题,例如:
write result to newList
文件格式奇怪:
listutxtÇhttp://url1.htmlutxtÇhttp://url2.htmlutxt~http://url3.htmlutxtzhttp:// ...
似乎也插入了空字符。那么,有人知道发生了什么吗?任何人都可以想办法:
a)将结果写为干净(最好是换行符分隔)txt? b)清理此输出以使其恢复正常?
感谢您的时间! 丹尼尔
答案 0 :(得分: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