Re: Novice question
Re: Novice question
- Subject: Re: Novice question
- From: Nigel Garvey <email@hidden>
- Date: Tue, 6 Nov 2001 14:34:03 +0000
"Alatorre, Michael" wrote on Mon, 5 Nov 2001 12:13:00 -0800 :
>
Hello all. I'm new to AppleScript (and this list), but learning to automate
>
my monthly report publishing to our ASIP server. I searching for a way to
>
create new monthly folders (without dialog input from me) when its time to
>
copy the report file(s) to the server. Our naming convention for these
>
folders is YYYY-MM (e.g., 2001-10). Is there a way in AppleScript to
>
incremently create a new folder once a month when it's time to post the
>
report? In other words, can I get it to read the last folder created then
>
correctly create and name the new one (taking into account when the year
>
rolls over)? Thank you in advance.
I'd tackle this the other way round: calculate what the folder name
should be for the current month and create the folder only if it doesn't
exist.
-- Calculate the "MM" part of the folder name
set today to current date -- or whatever date's required
copy today to d2
set d2's month to January
set monthIndex to text -2 thru -1 of ("0" & (1 + (today - d2) div
2419200))
-- Put the name together
set folderName to "" & today's year & "-" & monthIndex
-- Create the folder if it doesn't exist
-- (assumes folderLocation is a previously defined string)
tell application "Finder"
if not (exists folder folderName of folder folderLocation) then
make new folder at folder folderLocation with properties
{name:foldername}
end if
end tell
NG