If this has been asked elsewhere, or if I’m posting in the wrong spot, sorry, just direct me to the right page
I have learnt the basics of Applescript and now prefer learning by example. I am trying to do a very boring and repetitive task that could be done easily with scripting. I need to convert this text:
etc etc
To this:
etc etc.
It’s as simple as telling Applescript that after any four digits, a space, and then capital letter, to add a line break (return key). The problem is, I don’t know how to do this. I have about 30 pages of the original text, and Applescript will save me a lot of time. Again, this is a great learning experience for me (and time saving tool ), and if it’s in the wrong spot, move it/direct me to the right spot.
Thanks in advance!
Will
P.S. Sorry if my wording is confusing, just ask and I’ll try and make it easier to understand
Here a different approach assuming that all addresses contain “VIC” right before the number and the numbers are splitted into exactly 4 groups
set t to "Hamley Constructions Pty Ltd Thornbury VIC 3071 (03) 9416 9777 Hansen Yuncken Pty Ltd 25 Huntingdale Rd Burwood VIC 3125 (03) 9831 6500 Henley Properties Narre Warren VIC 3805 (03) 9705 6315 Henley Properties Group 395 Ferntree Gully Rd Mt Waverley VIC 3149 (03) 9574 5333 Homes Now Pty Ltd Level-4 150 Albert St South Melbourne VIC 3205 (03) 9686 1777"
set {TID, text item delimiters} to {text item delimiters, " VIC "}
set x to text items of t
set text item delimiters to space
set theList to ({item 1 of x} & "VIC" & text items 1 thru 4 of item 2 of x) as text as list
repeat with i from 2 to (count x) - 1
set end of theList to ({text items 5 thru -1 of item i of x} & "VIC" & text items 1 thru 4 of item (i + 1) of x) as text
end repeat
set text item delimiters to return
set theList to theList as text
set text item delimiters to TID
theList