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.
Jan 20
peter boardman Re: AppleScript and TextWrangler
Jan 20, 2010; 09:47
peter boardman
Re: AppleScript and TextWrangler
Jan 20
kthrose Re: AppleScript and TextWrangler
Jan 20, 2010; 10:57
kthrose
Re: AppleScript and TextWrangler
Search
Lasso Programming
This site manages and broadcasts several email lists pertaining to Lasso Programming and technologies related and used by Lasso developers. Sign up today!