Yuri Yuri - 5 months ago 35
AppleScript Question

Using AppleScript in Automator for replacing characters

I want to create service in Apple Automator to replace the characters to another ones. For instance, if I want to transform a phone number format:




Here is a Simple applescript code you can put in automator and it returns the output as a complete number = XXXXXXXXXX

on run {input, parameters}
    set inputNumber to input as text
    set outputNumber to ""
    if inputNumber begins with "+" then
        -- The Number begins with a + so convert number
        set noParts to the number of words of inputNumber
        repeat with cPart from 3 to noParts
            set outputNumber to outputNumber & word cPart of inputNumber
        end repeat
    end if
    return outputNumber
end run

Hope this helps!