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
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: