I am trying to figure out how to iterate through a file line by line in AppleScript. Similar to a bash script like so:
for LINE in $(cat file)
do
echo ${LINE}
done
Any tips? Thanks!
I can't take credit for writing this, I lifted the code from a response to a post in the MacRumors forums.
tell application "Finder"
set Names to paragraphs of (read (choose file with prompt "Pick text file containing track names"))
repeat with nextLine in Names
if length of nextLine is greater than 0 then
--Do something with the next name, which is stored in "nextLine"
end if
end repeat
end tell
Original code credit to HexMonkey on the MacRumors forum.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With