Applescript and localized dates

I’m looking for a way to have an applescript output the localized creation date for a file.
What I’m looking for is to have the output of the script which creates a folder with the month number + month name set to Dutch and not to English.

I’ve created the script and it runs quite well, but creates the folders with (f.e.) July instead of juli and August instead of augustus

So I get correct folders:

07-July
08-August
etc

But in the wrong language,

Any ideas on this one?
(note: localization settings on the mac are set to Dutch only)

Hello, as there is no code I can’t see how you generate your month string. From the current date?

In AppleScript you can get a localised date string with " text of date string"

For example:

#get the current date “woensdag 22 augustus 2018”
set DateString to text of date string of (current date)
#get the current month number
set MonthNumber to month of (current date) as integer
#add leading zero if needed
if MonthNumber < 10 then set MonthNumber to “0” & MonthNumber as text
#make the month string, eg. 08-augustus
set MonthString to MonthNumber & “-” & word 3 of DateString

BTW the forum software replaces the quotation marks with incorrect ones, if you get errors running the above script then you need to change them.

Just on the quote changing, if you surround your content with triple back ticks it marks it as a code block.

e.g.

```
Your text
```

So you could do something like this with the above:

#get the current date "woensdag 22 augustus 2018"
set DateString to text of date string of (current date)
#get the current month number
set MonthNumber to month of (current date) as integer
#add leading zero if needed
if MonthNumber < 10 then set MonthNumber to "0" & MonthNumber as text
#make the month string, eg. 08-augustus
set MonthString to MonthNumber & "-" & word 3 of DateString

Hope that helps.

1 Like

@FrankV and @sylumer

Thanks a lot guys, it worked…
It did not do as expected before but getting the string worked for me, and a bit of RegEx got the expected month as a result so it now works :slight_smile: