Iterating through a file line by line in AppleScript?

I am trying to figure out how to iterate over a file line by line in AppleScript. Like a bash script as follows:

for LINE in $(cat file) do echo ${LINE} done 

Any tips? Thanks!

+6
applescript
source share
1 answer

I can not take responsibility for this, I removed the code from the response to the message on the forums MacRumors.

 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 

The original HexMonkey loan code on the MacRumors forum.

+9
source share

All Articles