set startDate to getDate("Start Date")
set endDate to getDate("End Date")
set destinationFolder to (choose folder)
repeat until startDate > endDate
tell startDate to set {yr, mn, dy} to {year, its month as integer, day}
set folderName to (yr as text) & "." & pad(mn) & "." & pad(dy)
tell application "Finder" to make new folder at destinationFolder with properties {name:folderName}
set startDate to startDate + 1 * days
end repeat
on getDate(prompt)
repeat
set {text returned:textReturned} to display dialog prompt default answer ""
set {TID, text item delimiters} to {text item delimiters, "."}
set textItems to (text items of textReturned)
set text item delimiters to TID
if (count textItems) = 3 then
try
set currentDate to (current date)
tell currentDate to set {its hours, its minutes, its seconds} to {0, 0, 0}
tell currentDate to set {year, month, day} to textItems
return currentDate
end try
else
display dialog "bad format" buttons {"Cancel", "Try again"} default button 1
end if
end repeat
end getDate
on pad(v)
return text -2 thru -1 of ("00" & (v as text))
end pad
‘month’ is another date propery label which needs ‘its’ in front of it in this context. Also, when setting one date to another, the ‘day’ should be explicitly set below 29 first to avoid any possible overflow to another month.
try
set currentDate to (current date)
tell currentDate to set {day, time} to {1, 0}
tell currentDate to set {year, its month, day} to textItems
return currentDate
end try