How can I process one file at a time with this script

Joined
Oct 16, 2016
Messages
1
Reaction score
0
Points
1
Hello
I'm trying to process several text files in the selected folder but currently is only processing the first one.
Thanks in advance for your help.

set theSourceFolder to (choose folder with prompt "Select a folder:")

tell application "Finder"
set filesArray to (every file of theSourceFolder whose name ends with ".txt") as alias list
end tell

repeat with aFile in filesArray

tell application "TextWrangler"
set docName to name of (open aFile)
tell document docName
set its text to copied lines of (process lines containing matching string "(?m)^Answer : (.+)" with matching with grep)
set idText to found text of (find "" options {search mode:grep, starting at top:true})
replace "Answer : " using idText options {search mode:grep, starting at top:true}


close saving yes
end tell
end tell
end repeat
 
Last edited:

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top