I hope I’m not repeating another post. My search returned a ton of topics that seemed to be identical (not to my question, but to themselves), so if you know for certain this is a repeat then just point me in the right direction, otherwise:
All my teachers use powerpoints, and I find it beneficial to turn these into pdf’s (I annotate with Skim then export as text outline). My issue is for certain letters, or letter combinations, the exported text is replaced with a variety of different characters. Also, this only happens with a select few pdf’s, most are exported correctly.
Here are some examples: Propriocep4ve, Posi+on, Contraindica%ons, a`achments, LeZ, sta-cally, Lingual$nerve, vestibule, supraglo.c, respiratory)center
As you can see the overwhelming concern here is the substitution of “ti” with the substitution of space as a close second. (I gave more examples of “ti” but the space is also a concern). These are the only two cases I want to manipulate as they are the most frequent.
I was thinking that I could assign variables: theLetters (upper- & lowercase), theNumbers, thePunctuation
Then do something similar to the below. However, I know this is incorrect 1. because it fails miserably, 2. because it doesn’t automatically choose the erroneous character in the handler, and 3. It doesn’t take into account the situation where both the “ti” and a " " are misrepresented. Any pointers are most appreciated.
set theFile to choose file --a .txt file
set theText to read theFile
set theTextList to paragraphs of theText
set theLetters to {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
set theNumbersAndPunctuation to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "!", "#", "%", "'", "+", "-", "."}
--set thePunctuation to {"!", "#", "%", "'", "+", "-", "."}
set theWrongSpaces to {"$", "(", ")"}
if characters of theTextList contains (items of theLetters & items of theNumbersAndPunctuation & items of theLetters) then
set newText to my replaceChar(theTextList)
else if items of theTextList contains (items of theLetters & items of theWrongSpaces & items of theLetters) then
set newText to my replaceSpace(theTextList)
end if
on replaceChar(noteText)
set tid to text item delimiters
set text item delimiters to "4" -- here i want the script to automatically choose charachter in error
set newText to every text item in noteText
set text item delimiters to "ti"
set finalText to every item in newText as text
set text item delimiters to tid
return finalText
end replaceChar
on replaceSpace(noteText)
set tid to text item delimiters
set text item delimiters to "4" -- here i want the script to automatically choose charachter in error
set newText to every text item in noteText
set text item delimiters to " "
set finalText to every item in newText as text
set text item delimiters to tid
return finalText
end replaceSpace