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
This is the code I have so far, that isn't working although it seems
it should. This code was giving me grief with TextEdit, so I opted to
use TextWrangler because of how immense the script library was in
comparison.
on opening folder this_folder
set varDate to date string of (current date) as text
set varFolderPath to this_folder as Unicode text
set varFilePath to (varFolderPath & varDate & ".rtf")
set boolFileExists to varFilePath exists
tell application "TextWrangler"
launch
if boolFileExists then
display alert "This file already exists and is being
opened and
appended."
open for access varFilePath with write permission
write return
else
set E to make new document with properties
{name:varDate}
tell E
display alert "This file does not exist, and is
being created
now."
set its text to (varDate)
save to file (varFilePath)
end tell
end if
end tell
end opening folder
Thanks much for your help in advance! I'm trying to use this to
automate my notetaking for school - I had a functional script before
but when I updated to Snow Leopard, my scripts disappeared! I was
hoping I could adapt my old script from last semester to this
semester, but the script is ghost.
--
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.