I have selected a list of files in Applescript using:
set variableName to do shell script "cd /; cd dev/; ls tty.usb*"
When I print out variableName, it shows this list:
file1
file2
From here, I want to loop through each of them using:
repeat with theItem in variableName
display dialog theItem
end repeat
Instead of showing "file1" and "file2" one by one, it shows "f, i, l, e, 1," and so forth.
How can I loop the list to get a complete file name?
Thanks for the helpful responses! I have found out the solution.
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
By using paragraphs, I'm able to split by newline and covert the result into a list.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.