Macos Applescript循环通过“的结果”;ls";加上;do shell脚本“;

Macos Applescript循环通过“的结果”;ls";加上;do shell脚本“;,macos,unix,applescript,Macos,Unix,Applescript,我已在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”

我已在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

通过使用段落,我可以按换行符拆分并将结果转换为列表。

注意,您可以在终端中输入以下内容:
find/dev/-name“tty.usb*”-exec osascript-e'display dialog“{}”\将myList设置为variableName的每个段落。然后,您必须遍历myList的每个元素。@Yoric谢谢!它就像终端中的魅力,但我打算在applescript中这样做。有并没有办法把这段代码转换成applescript?@pbell你们的意思是:“将testList设置为variableName的段落?”?它显示了这样的结果:“无法获取“我的ls输出”的段落。您使用的是
find
,而不是
ls
,如果您要利用结果,这是更可取的。