Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

vloryan

macrumors member
Original poster
Jan 11, 2014
57
0
hi guys,

i have a date in a txt-file looking like this:

16.08.2014

and would like to change this to

SA.16.08.14

using apple script. any chance to do this? thanks!
 
In AppleScript, the & operator is used to concatenate (join) strings, so by joining the various text elements in the desired sequence you can make your new string - for example:

Code:
set originalString to "16.08.2014" -- your example text
tell originalString to set newString to "SA." & text 1 thru 6 & text 9 thru 10
return newString
 
yes, thats what i want, but the date must be read from a date.txt file...
 
What have you got so far - are you looking for a general-purpose handler to do the date modification, or are you looking for a complete script? Does the date need to be extracted from other text in the text file? Your date is not in a US format - are the dates in the text file the same as the localization you are using?

You need to be more specific about every detail of what you are trying to do, so we don't have to continue playing this guessing game.
 
yes, thats what i want, but the date must be read from a date.txt file...

might be of help to the script guru's to show the output of what this date.txt file looks like.


Not sure about the applescripting part, just tinkered with it tbh, but if it works like most languages you are looking at a line read from text file into a variable type of some kind, doing something like red menace has suggested to that variable and line write out to what you wanted (ideally to a new txt file to keep source intact, just a preference here though).

Show this date.txt file and they may be able to help you better. I for example am wondering if is just one line of text, the date, or several lines of dates. In any language how you would add the day abbreviation would be based on this.

Not doubting you per se...but if true I am wondering what app you are using that bothers to create a file with just one date...and no other information to show its meaning. And then on Sun the 17th....either creates a new file or overwrite the old one, again with just single date, no information.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.