My problem: Putting a (text) file I create into a folder that is not one of the “path to” constants.
try
tell me to activate
set saveFile to button returned of (display dialog "Do you want to save this page?" buttons {"Yes", "No"} default button 2 with icon note)
if saveFile = "Yes" then
set title to text returned of (display dialog "Enter title for text: " default answer "")
set title to title & ".txt"
tell application "Firefox"
activate
end tell
tell application "System Events" to keystroke "a" using {command down}
tell application "System Events" to keystroke "c" using {command down}
tell me to activate
set selecTxt to the clipboard as text
tell application "Firefox" to activate
set dat to (current date) as text
*--set clipFil to (path to desktop folder as text) & title
*set clipFil to (path to "Macintosh HD:Users:sw:Desktop:writing" as text) & title
try
close access file clipFil
end try
set filRef to open for access file clipFil with write permission
write (dat & return & selecTxt & return & "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & return & return) to filRef starting at eof
close access filRef
end if
end try
The starred lines are the ones I’m working with. I’ve looked at POSIX FAQs too, but I don’t understand how to apply them. The first line works, but I don’t want the files I’m creating to go to the Desktop. I want them to go to the folder in Desktop called “writing.”
Extras:
So, intro post for me. I just started on Applescript today. I have prior programming experience in other languages though. This code is a mish mash of other code examples I’ve been looking at most of the day. I like to read a lot of online writing and I was trying to create something that would make it so I don’t have to “select(long sections)-copy-paste-save” over and over. And this is for very specific formatting right now, but if I can understand how to do this saving, I can definitely apply it to other things.
Thank you!
Model: MacBook Pro
AppleScript: 2.3
Browser: Firefox 5.0
Operating System: Mac OS X (10.6)