Re: Novice question
Re: Novice question
- Subject: Re: Novice question
- From: "Marc K. Myers" <email@hidden>
- Date: Mon, 05 Nov 2001 17:54:40 -0500
- Organization: [very little]
>
From: "Alatorre, Michael" <email@hidden>
>
To: "'email@hidden'"
>
<email@hidden>
>
Subject: Novice question
>
Date: 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.
If the folders are in the same container and there are no other folders
there you can use the Finder to sort the contents of the container by
modification date and select the first item of the resulting list. This
will be the last folder created.
You can parse the folder's name into year and month like this:
set theYear to text 1 thru 4 of theName
set theMonth to text 6 thru 7 of theName
if (theMonth as integer) + 1 > 12 then
set theMonth to "01"
set theYear to ((theYear as integer) + 1) as text
else
set theMonth to text -2 thru -1 of "0" & ((theMonth as integer) + 1)
as text
end if
set theName to theYear & "-" & theMonth
tell application "Finder"
make new folder at theContainer with properties {name:theName}
end tell
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[11/5/01 5:54:28 PM]