(* Address Book Converter ( Kuwait Plan ) Mohammed Al-Kout mjkout@gmail.com http://www.q8i.org Feel free to change if required *) (* Change Log : v 1.1 : simplified code got rid of redundant if statements *) tell application "Address Book" repeat with p in (get people) set x to count phones of p repeat with n from 1 to x set m to (value of phone n of p) if (length of m = 6 or length of m = 7) then set m to m else if (length of m > 7 and (m begins with "00965" or m begins with "+965" or m begins with 965)) then set m to characters -7 thru -1 of m as text end if if (m as text is greater than or equal to 2000000 and m as text is less than or equal to 3999999) then set (value of phone n of p) to "+9652" & m else if (m as text is greater than or equal to 4100000 and m as text is less than or equal to 4399999) then set (value of phone n of p) to "+9652" & m else if (m as text is greater than or equal to 4500000 and m as text is less than or equal to 5009999) then set (value of phone n of p) to "+9652" & m else if (m as text is greater than or equal to 5030000 and m as text is less than or equal to 5049999) then set (value of phone n of p) to "+9652" & m else if (m as text is greater than or equal to 5200000 and m as text is less than or equal to 5499999) then set (value of phone n of p) to "+9652" & m else if (m as text is greater than or equal to 5510000 and m as text is less than or equal to 5539999) then set (value of phone n of p) to "+9652" & m else if (m as text is greater than or equal to 5600000 and m as text is less than or equal to 5699999) then set (value of phone n of p) to "+9652" & m else if (m as text is greater than or equal to 5710000 and m as text is less than or equal to 5779999) then set (value of phone n of p) to "+9652" & m else if (m as text is greater than or equal to 4000000 and m as text is less than or equal to 4099999) then set (value of phone n of p) to "+9659" & m else if (m as text is greater than or equal to 4400000 and m as text is less than or equal to 4499999) then set (value of phone n of p) to "+9659" & m else if (m as text is greater than or equal to 7020000 and m as text is less than or equal to 7029999) then set (value of phone n of p) to "+9659" & m else if (m as text is greater than or equal to 7100000 and m as text is less than or equal to 7699999) then set (value of phone n of p) to "+9659" & m else if (m as text is greater than or equal to 7800000 and m as text is less than or equal to 7999999) then set (value of phone n of p) to "+9659" & m else if (m as text is greater than or equal to 9000000 and m as text is less than or equal to 9999999) then set (value of phone n of p) to "+9659" & m else if (m as text is greater than or equal to 5010000 and m as text is less than or equal to 5029999) then set (value of phone n of p) to "+9656" & m else if (m as text is greater than or equal to 5050000 and m as text is less than or equal to 5199999) then set (value of phone n of p) to "+9656" & m else if (m as text is greater than or equal to 5500000 and m as text is less than or equal to 5509999) then set (value of phone n of p) to "+9656" & m else if (m as text is greater than or equal to 5540000 and m as text is less than or equal to 5599999) then set (value of phone n of p) to "+9656" & m else if (m as text is greater than or equal to 5700000 and m as text is less than or equal to 5709999) then set (value of phone n of p) to "+9656" & m else if (m as text is greater than or equal to 5780000 and m as text is less than or equal to 7019999) then set (value of phone n of p) to "+9656" & m else if (m as text is greater than or equal to 7030000 and m as text is less than or equal to 7099999) then set (value of phone n of p) to "+9656" & m else if (m as text is greater than or equal to 7700000 and m as text is less than or equal to 7769999) then set (value of phone n of p) to "+9656" & m else if (m as text is greater than or equal to 7780000 and m as text is less than or equal to 7799999) then set (value of phone n of p) to "+9656" & m else if (m as text is greater than or equal to 800000 and m as text is less than or equal to 899999) then set (value of phone n of p) to "1" & m end if end repeat end repeat end tell