I am trying to create a script to extract a list of data from column A on document 1, and then use columns A & B on document 2 as multiple find/replace data.
Everything works in so far as grabbing the data required but I don't understand how to write the script to do the find/replace. I want it to run through the entire list from document 1 whilst referencing the first row of the find/replace list (document 2), and then to do the same with row 2, and so on until it reaches the end of document 2.
You will see how I have tried to execute this at the bottom but I don't understand how this should be written. I'd really appreciate some pointers here if anyone would care to help me.
-- set paths
tell application "Finder"
set folderpath to folder "Macintosh HD:Users:Will:Desktop:Data1"
set filePath to first file of folderpath as alias
set folderpath2 to folder "Macintosh HD:Users:Will:Desktop:Data2"
set filePath2 to first file of folderpath2 as alias
end tell
-- grab data
set fileRefr to (open for access filePath)
set theText to (read fileRefr)
set textList to paragraphs of theText
close access fileRefr
set uniqueList to {}
set dataList to every paragraph of (do shell script "cat " & quoted form of POSIX path of filePath & " | awk -F'" & tab & "' 'BEGIN{getline}{print $1}'")
set uniqueList to uniqueList & dataList
set fileRefr2 to (open for access filePath2)
set theText2 to (read fileRefr2)
set textList2 to paragraphs of theText2
close access fileRefr2
set theCNT to (count of textList2) - 1
set uniqueList2 to {}
set dataList2 to every paragraph of (do shell script "cat " & quoted form of POSIX path of filePath2 & " | awk -F'" & tab & "' 'BEGIN{getline}{print $1}'")
set uniqueList2 to uniqueList2 & dataList2
set uniqueList3 to {}
set dataList3 to every paragraph of (do shell script "cat " & quoted form of POSIX path of filePath2 & " | awk -F'" & tab & "' 'BEGIN{getline}{print $2}'")
set uniqueList3 to uniqueList3 & dataList3
-- find/replace data
repeat with i from 1 to count theCNT
set uniqueList to (replace_chars of uniqueList from (item i of uniqueList2) to (item i of uniqueList3))
end repeat