I have found an AppleScript below that finds and replaces... However instead of replacing with "401" in this case I want it to replace with what is on the clipboard.
So I am trying to put something like: set stringToReplace to keystroke "v" using command down...But that doesn't work (Expected end of line, etc. but found identifier.)
Here is the code:
on run {input, parameters}
    set stringToFind to "404"
    set stringToReplace to "401"
    set theFile to choose file
    set theContent to read theFile as «class utf8»
    set {oldTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, stringToFind}
    set ti to every text item of theContent
    set AppleScript's text item delimiters to stringToReplace
    set newContent to ti as string
    set AppleScript's text item delimiters to oldTID
    try
        set fd to open for access theFile with write permission
        set eof of fd to 0
        write newContent to fd as «class utf8»
        close access fd
    on error
        close access theFile
    end try
    return input
end run
				
                        
Solved the issue:
All I needed to do was add:
the clipboardafterset stringToReplace to