NEWBIE - Save to File made up of Date - Help?

Hi All,
I am still new to the world of Applescript, so please, be gentle.
I am trying to design an Applescript which will access a specific URL, and download the webpage as an HTML File to my MacIntosh HD.
This works fine, when I specify the name that I want to save it as, however, as I want this to be done daily, and I want to archive each day’s result, I want to have the Script calculate the name to save as using the following format “YYMMDD.htm” (YY=Last 2 Digits of Year, MM = Month - with leading zero, DD = Day - with leading zero)
My script, as it stands is:

tell application "Finder"
select file " 6. Netscape" of folder "Applications" of folder "Apple Menu Items" of folder "System Folder" of startup disk
open selection 
end tell 
tell application "Netscape Communicator™"
GetURL "" to file "020326.htm"
end tell

It is the ’ to file “020326.htm” ’ section which I need to change.
If anyone could assist me with this, I would be truly appreciative.
(Please email me at
Thank You

Looks like what you want is:

GetURL "" to file "My Hard Drive:Some Folder:020326.htm"

The “to file” portion wants a complete file path. Post again if you need further assistance.
Be well.

Hi TJ,

Well, the answer provided has sorted out a second question, but what I need to know is how to make the script calculate the name for the file.

E.g. on 26/03/02, I want it to save to 020326.htm,
on 27/03/02, I want it to dave to 020327.htm, etc…

I will incorporate your suggestion regarding the full path into the script. If you have any suggestions for calculations to perform the above, it would be appreciated.
Thanks Again.

This will create the file name. If you need help incorporating it into your script, let us know.

set monthNums to {{January, "01"}, {February, "02"}, {March, "03"}, {April, "04"}, {May, "05"}, {June, "06"}, ¬
	{July, "07"}, {August, "08"}, {September, "09"}, {October, "10"}, {November, "11"}, {December, "12"}}
set currDate to (current date)
set currDay to day of currDate

if (count of (currDay as text)) is 1 then set currDay to "0" & currDay as text

set currYear to text -2 thru end of (year of currDate as text)

repeat with i in monthNums
	if month of currDate is equal to item 1 of i then
		set currMonth to item 2 of i
		exit repeat
	end if
end repeat

set fileName to currYear & currMonth & currDay & ".htm" as text
-- Result --> "020326.htm"

Here’s another possibility.

set fileName to dateAsYYMMDD(current date) & ".htm"
set filePath to (path to desktop as string) & fileName -- if you want to save on desktop

tell app "URL Access Scripting" -- if you have Mac OS 8.6 or later
download "" to file filePath without progress

on dateAsYYMMDD(incomingDate)
	-- NEEDS getMonthNum()
	-- version 1.0
	set textYear to text 1 through 2 of (year of incomingDate as string)
	set textMonth to month of incomingDate as string
		set textMonth to my getMonthNum(incomingDate) as string
	on error -- JUST IN CASE HANDLER IS MISSING, use this simple one
		-- the plain vanilla get month number function - I believe I found it on macscripter.ent
		--set theDate to the current date --or any other date
		copy incomingDate to b
		set the month of b to January
		set monthNum to (1 + (theDate - b + 1314864) div 2629728)
		set textMonth to monthNum as string
	end try

	if length of textMonth is 1 then set textMonth to "0" & textMonth
	set textDay to day of incomingDate as string
	if length of textDay is 1 then set textDay to "0" & textDay

	return textYear & textMonth & textDay

end dateAsYYMMDD

on getMonthNum(theDate)
	--set theDate to the current date --or any other date
	-- the plain vanilla get month number function - I believe I found it on macscripter.ent
	copy theDate to b
	set the month of b to January
	set monthNum to (1 + (theDate - b + 1314864) div 2629728)
	return monthNum
end getMonthNum 

This means that the file will download without launching Netscape or any web browser. You could also change the without progress to ‘with progress’ to see when it happens. You can read more about URL Access Scripting in this BBS archive

The post dates on this are pretty old but just in case someone comes back to this thread here’s a way to do it in 1 line of code. You do need the DateTime addition which is free.
You can find it here-

It comes with a legend for formating the date and time.

I think what you are looking for could be achieved with:

set MyDate to DateTime “%y%m%d”

Hope this helps