This was the ticket - works great with TextWrangler. Thanks for
showing me how to use the Date properly as well - I was having trouble
accessing just the month and day of current_date before. I guess my
major problem was all of the "as text" and "as string" pieces - I was
assigning onjects and not typecasting them properly.

Thanks again!

On Jan 20, 12:47 pm, peter boardman <[email protected]> wrote:
> On 20 Jan 2010, at 04:32, kthrose wrote:
>
> > Hey guys. I'm trying to create a script for a Folder Action that is
> > designed something like this:
>
> > when the folder opens
> > check to see if there exists a file called (current_date).rtf in
> > this_folder
> > if true
> > open file and return, so the user can begin at the EOF writing
> > if false
> > create new file called current_date.rtf, write current_date as string
> > to top of file, and save as current_date.rtf in this_folder
>
> Try something like this to get you started. I'm using BBEdit these days, but 
> hopefully TW will work.
>
> on opening folder this_folder
>         set today to current date
>         set varDate to day of today & month of today & year of today
>         set varFolderPath to this_folder as Unicode text
>         set varFilePath to (varFolderPath & varDate & ".txt")
>         tell application "Finder"
>                 if exists file varFilePath then
>                         set boolFileExists to true
>                 else
>                         set boolFileExists to false
>                 end if
>         end tell
>
>         tell application "BBEdit"
>                 activate
>                 if boolFileExists then
>                         display alert "This file already exists"
>                         open varFilePath
>                         select insertion point after last line
>                 else
>                         display alert "This file does not exist"
>                         set E to make new document with properties 
> {name:varDate as string}
>                         tell front window
>                                 select insertion point after last line
>                                 set selection to ((current date) as text) & 
> return
>                                 select insertion point after last line
>                         end tell
>                         save front text document to varFilePath
>                 end if
>         end tell
> end opening folder
-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "[email protected]" rather than posting to the group.

Reply via email to