Open the AppleScript Editor in the /Applications/Utilities/ folder and run:
set the_string to "4775"
set new_string to "-"
if (count the_string) is 4 then
set the_list to items 2 thru 4 of the_string
repeat with this_char in the_list
if (this_char as number) is in {4, 5, 6, 7} then
set new_string to new_string & "r"
else
set new_string to new_string & "-"
end if
if (this_char as number) is in {2, 3, 6, 7} then
set new_string to new_string & "w"
else
set new_string to new_string & "-"
end if
if (this_char as number) is in {1, 3, 5, 7} then
set new_string to new_string & "x"
else
set new_string to new_string & "-"
end if
end repeat
set new_string to items of new_string
if (item 1 of the_string as number) is in {4, 5, 6, 7} and item 4 of new_string is "x" then set item 4 of new_string to "s"
if (item 1 of the_string as number) is in {4, 5, 6, 7} and item 4 of new_string is "-" then set item 4 of new_string to "S"
if (item 1 of the_string as number) is in {2, 3, 6, 7} and item 7 of new_string is "x" then set item 7 of new_string to "s"
if (item 1 of the_string as number) is in {2, 3, 6, 7} and item 7 of new_string is "-" then set item 7 of new_string to "S"
if (item 1 of the_string as number) is in {1, 3, 5, 7} and item 10 of new_string is "x" then set item 7 of new_string to "t"
if (item 1 of the_string as number) is in {1, 3, 5, 7} and item 10 of new_string is "-" then set item 7 of new_string to "T"
return new_string as string
end if
if (count the_string) is 10 then
set new_number to 0
considering case
if item 2 of the_string is "r" then set new_number to new_number + 400
if item 3 of the_string is "w" then set new_number to new_number + 200
if item 4 of the_string is "x" then set new_number to new_number + 100
if item 4 of the_string is "s" then set new_number to new_number + 4100
if item 4 of the_string is "S" then set new_number to new_number + 4000
if item 5 of the_string is "r" then set new_number to new_number + 40
if item 6 of the_string is "w" then set new_number to new_number + 20
if item 7 of the_string is "x" then set new_number to new_number + 10
if item 7 of the_string is "s" then set new_number to new_number + 2010
if item 7 of the_string is "S" then set new_number to new_number + 2000
if item 8 of the_string is "r" then set new_number to new_number + 4
if item 9 of the_string is "w" then set new_number to new_number + 2
if item 10 of the_string is "x" then set new_number to new_number + 1
if item 10 of the_string is "t" then set new_number to new_number + 1001
if item 10 of the_string is "T" then set new_number to new_number + 1000
end considering
return new_number
end if
(83221)