problems copying and item from Resources to /tmp

Hello,

I am looking for a scripting addition that helps me format dates and time to put a stamp on a file name. Like:

formatdate (currentdate) using “dd-mm-yyy hhHmm”"

I have found the CLOCK verb in the AKUA SWEET but it gives the Macintosh clock time stamping. The file stamping cannot use semi colon (:slight_smile: because it is not autorise in a file name. I have found nothing is AS nor MS databases ?? Thanks in advance.

Robert Lespérance
Québec, Canada

Hi :slight_smile:

You can formated the current date without using any OSAX, with, for exemple, this famous NG’s Vanilla routine:

--Short Date by Nigel Garvey
set TheCurrentDate to (current date)
set TheFullDate to "" & my shortDate(TheCurrentDate) & " " & (time string of TheCurrentDate)
--> "12-31-03 2:44:56"
on shortDate(theDate)
	copy theDate to newDate
	set month of newDate to January
	tell (((year of theDate) * 10000 + (newDate - 2500000 - theDate) ¬
		div -2500000 * 100 + (day of theDate)) as string) to return ¬
		text 5 thru 6 & "-" & text 7 thru 8 & "-" & text 3 thru 4 -- US format 
end shortDate

:wink:

Thanks Fredo,

Do you have access to a version of the script that could give me another format like:

dd-mm-yy hhmm

Or even better if those script are available as OSAX ?? Thanks again.

:wink:

Here one suggestion:

--Short Date by Nigel Garvey, with a insignificant adaptation by Fredo d;o)
set TheCurrentDate to (current date)
set TheCurrentTime to time string of TheCurrentDate

set TheFullDate to "" & my shortDate(TheCurrentDate) & " " & (text -8 thru -4 of ("0" & TheCurrentTime))
--> "31-12-03 06:18"

on shortDate(theDate)
	copy theDate to newDate
	set month of newDate to January
	tell (((year of theDate) * 10000 + (newDate - 2500000 - theDate) ¬
		div -2500000 * 100 + (day of theDate)) as string) to return ¬
		text 7 thru 8 & "-" & text 5 thru 6 & "-" & text 3 thru 4 -- Fr format 
end shortDate

:wink:

Thank you Fredo et Billary for your comments and script.

I have also found 2 scripting additions that are very simple to use in date formatting: DATE STRING FOR and TIME STRING FOR.

set shorttime to time string for (current date) without seconds
set shortdate to date string for (current date) in short format
set stamp to shortdate & " " & shorttime

the result looks like ----> 02-01-03 0:43

Thanks for everything.

Hi :slight_smile:

Ho, Ok, very nice :slight_smile:
But, what is the name of these OSAX ? or link to download ?
Thanks :slight_smile:

Hello Fredo,

Search in MacScripter Scripting additions’s section for TIME STRING FOR or DATE STRING FOR. Or look at this link … http://osaxen.com/gtq_scripting_library.html