How can I read a file one line at a time?

I’m getting started writing an AppleScript whose purpose is to rename a whole lot of folders; the basic story is that we’ll be backing up a lot of data on 1000+ machines and replacing 300+ of them with new ones, and want the data restored to the new machines.

Each backup is placed in a folder whose name is the ethernet address of the machine it was backed up from. Our Restore script looks at the current machine’s ethernet address and then looks to see if there’s a matching backup. So, since we’ll be switching 300+ machines out between the backup and the restore, we just need some way to change the names of the backup folders and all should be well.

What I’d like to do is to have one text file with a line per rename; something like:
,

…and have the renamer AppleScript look at this text file line by line, look for a folder matching the first ethernet address, and rename it to the second ethernet address.

Since this is going to be a long-ish text file, I assume it’d be inefficient to read the whole thing into a text string in AppleScript, right?

Can anyone offer any pointers? Thanks!

No. You can read the whole file in at once as paragraphs which will immediately break it into a list. Then iterate through that list splitting it at the comma:

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Thanks; you’re awesome! :smiley:

Thanks; you’re awesome! :smiley:

If anyone’s interested, here’s my finished script:


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]