Add Date to Folder Name

Here is another option… By creating the new variable set newDatedFolder to … To the process of making that new folder as I did below, now the rest of the code in your script can interact with that new folder. And for an example I showed the code for duplicating all of the items in my documents folder to the new newDatedFolder

tell application "Finder"
	set newDatedFolder to (make new folder at desktop with properties ¬
		{name:"MacBook Pro Documents " & ((my year of (current date) & "-" & ¬
			(my month of (current date) as number) as text) & "-" & my day of (current date))}) as alias
	delay 0.1
	duplicate items of my (path to documents folder) to newDatedFolder
end tell

Now that opens up some interesting possibilities, but I ran into an issue. I changed your script as follows:

tell application "Finder"
	set newDatedFolder to (make new folder at desktop with properties ¬
		{name:"MacBook Pro Documents " & ((my year of (current date) & "-" & ¬
			(my month of (current date) as number) as text) & "-" & my day of (current date))}) as alias
	delay 0.1
	duplicate items of my (path to "Macintosh HD:Users:Homer:Photos Archive:Old School Aircraft") to newDatedFolder
end tell

And I end up with an error (see screenshot).

Hi @wch1zpink.

Besides calling the current date function three times in a row, the code doesn’t cater for leading zeros.

@Homer712. The path to command takes predefined keywords and only works for certain folders known to the system. You need to specify your folder explicitly, as follows:

tell (current date) to tell (100000000 + 10000 * (its year) + 100 * (its month) + (its day)) as text to set ISODate to text 2 thru 5 & "-" & text 6 thru 7 & "-" & text 8 thru 9
tell application "Finder"
	set newDatedFolder to (make new folder at desktop with properties ¬
		{name:"MacBook Pro Documents " & ISODate}) as alias
	delay 0.1
	--duplicate items of my (path to documents folder) to newDatedFolder
	
	-- Homer712's change corrected:
	duplicate items of folder "Macintosh HD:Users:Homer:Photos Archive:Old School Aircraft" to newDatedFolder
	-- Or:
	duplicate items of folder "Photos Archive:Old School Aircraft" of home to newDatedFolder
end tell

Hi @Nigel_Garvey
Besides calling the current date function three times in a row, the code doesn’t cater for leading zeros.

I addressed calling (current date) three times in a row but needed to add more code to do that. I’m also not quite sure what you mean by leading zeros.

set theDate to (current date)

set {theYear, theWeek, theDay} to {year of theDate, month of theDate as number, day of theDate}

tell application "Finder"
	set newDatedFolder to (make new folder at desktop with properties ¬
		{name:"MacBook Pro Documents " & theYear & "-" & ¬
			theWeek & "-" & theDay}) as alias
	delay 0.1
	duplicate items of my (path to documents folder) to newDatedFolder
end tell

Zeros in front of single-digit numbers for months and days, as in “2025-01-01”.

Thank you. Both paths (duplicate items of folder “Macintosh HD:Users:Homer:Photos Archive:Old School Aircraft” to newDatedFolder) and (duplicate items of folder “Photos Archive:Old School Aircraft” of home to newDatedFolder) work equally well. And, I’ve learned something yet again.