Re: New Folder with date
Re: New Folder with date
- Subject: Re: New Folder with date
- From: Sander Tekelenburg <email@hidden>
- Date: Fri, 6 Apr 2001 04:32:14 +0200
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
At 23:31 +0900 UTC, on 05/04/2001, Stephen Wheeler (Saito) wrote:
>
Hello,
>
>
I have this script which makes a folder with today's date,
>
>
tell application "Finder"
>
set aDate to current date -- today's date
>
set yy to year of aDate
>
set mm to month of aDate
>
set dd to day of aDate
>
set myFile to (yy & "/" & mm & "/" & dd) as text -- file name
>
make new folder with properties {name:myFile}
>
end tell
Only the last line of that needs to be within a Finder tell block. In this
case it doesn't actually _hurt_ to have it all in a Finder tell block, but it
obscures from yourself what is actually going on - what is doing what. And in
some other cases it _can_ hurt, so then you'll still need to know what and
why. So it's considered "good practice" to only put in an application tell
block what actually needs to be there.
>
But I want to return the month as a number and not a name.
Shamelessly copied from <
http://homepage.mac.com/dlivesay/aclafaq.html>:
set theDate to the current date
copy theDate to b
set the month of b to January
set monthNum to (1 + (theDate - b + 1314864) div 2629728)
There's something clever going on there, but my math sucks. So hopefully
someone else can explain this little gem.
>
Also the next thing I want to do with this script is to copy a folder
>
named "db"into this newly made dated folder.
Change the last line of your script to:
set NewFolder to make new folder with properties {name:myFile}
Now you can refer to the newly created folder through the "NewFolder"
variable.
Now you can simply tell the Finder to
set db to choose folder -- or hard code the path
copy db to NewFolder
HTH
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <
http://www.pgp.com>
iQA/AwUBOs0qpesywKfXgqKdEQKY/QCfTiiwSvFpB4GnOw9oQ5sXfmrbPOAAoIny
mlW+2tstCW7Go4YZBoFtqxpy
=4AaF
-----END PGP SIGNATURE-----
--
Sander Tekelenburg, <
mailto:email@hidden>
Web site at <
http://www.euronet.nl/~tekelenb/>
Mac user: "Macs only have 40 viruses, tops!"
PC user: "SEE! Not even the virus writers support Macs!"