[英]Applescript loop through result of “ls” with “do shell script”
我已使用以下命令在Applescript中选择了文件列表:
set variableName to do shell script "cd /; cd dev/; ls tty.usb*"
当我打印出variableName时,它显示以下列表:
文件1
文件2
从这里开始,我想使用以下命令遍历每个对象:
repeat with theItem in variableName
display dialog theItem
end repeat
与其一一显示“ file1”和“ file2”,不如显示“ f,i,l,e,1”等等。
如何循环列表以获取完整的文件名?
感谢您的有用回复! 我找到了解决方案。
set variableName to do shell script "find /dev/tty.usb*"
display dialog variableName
set testArray to paragraphs of the variableName
repeat with theItem in testArray
display dialog theItem
end repeat
通过使用段落,我可以按换行符拆分并将结果隐式转换为列表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.