The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniOutliner > OmniOutliner 3 for Mac
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Applescript save? Thread Tools Search this Thread Display Modes
I cannot seem to figure out how to save an OO file using data I have from the file. Here's what I'd like to do:

grab the contents of a row and make that be the filename
save the file with that name in a certain folder (which is hard-coded).

Hopefully I'm just doing something stupid, but I'd sure appreciate some help here!

My simple code that "should" work:

set thepath to "/Users/wblj/myfolder/" as text
-- go take a look at the front doucment:
set thedoc to document 1
-- go get the user-specified filename from the column title:
set thetitle to title of column 2 of thedoc
-- Set the document to know where to save itself:
set properties of thedoc to {name:(thetitle), path:(thepath)}
-- Save away
save thedoc

What happens is the the file saves itself as a folder / xml file at the root of the drive. Not what I had in mind.

I've tried variations:

set thepath to "/Users/wblj/myfolder/" as text
-- go take a look at the front doucment:
set thedoc to document 1
-- go get the user-specified filename from the column title:
set thetitle to title of column 2 of thedoc

-- Save away
set thenewpath to thepath & thetitle
save thedoc in (thenewpath as string)

This does exactly what I have in mind, except that the file doesn't know where it saved itself, so you cannot do additional saves form the app :-(

Any help would be most appreciated!
 
this should work:

Code:
	set thepath to "/Users/wblj/myfolder/" as string
	-- go take a look at the front doucment:
	set thedoc to document 1
	-- go get the user-specified filename from the column title:
	set thetitle to title of column 2 of thedoc
	--save the file
	save thedoc in (thepath & thetitle)
	--if the file is already saved as something, then "save" will do a "save to" instead of "save as"
	--so you'll need to close the old file and open the new one
	close thedoc
	open (thepath & thetitle & ".oo3")
The issue is that the normal AS "save" command does a "save as" if it's an untitled document and "save to" otherwise. So if you use this script on a new unsaved file, you can omit the last two lines that close and open the new document. But if you're trying to rename the file, you'll need those last lines.
 
Hi, thanks for replying. This leaves something to be desired; the close makes OO ask if the document should be saved, since it somehow things it has not yet been saved. It does work, just isn't desirable. My goal was to create a new doc, start typing in it, which includes the filename, and at some point save and perhaps keep working, all with just a keystroke. This is certainly workable, but not very close to what I had in mind. Seems like "save" should have some additional flexibility / options? Should I make a feature enhancement request?
 
oh, forgot to mention that. Since I don't really know how you're using the script I didn't want to fix that. If you just tell it to save thedoc before it closes, then you won't get prompted. This will of course mean those changes are saved to the original file, not just under the new copy. If that doesn't matter, then it's a simple fix.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How I save a perspective with AppleScript? kroger OmniFocus Extras 2 2012-03-23 10:56 PM
Applescript to Save Clipboard to Clippings? jamespro OmniOutliner 3 for Mac 0 2011-03-23 11:11 AM
AppleScript save as PDF - how can I get the whole page? jerremy OmniGraffle General 7 2009-03-14 03:17 PM
Applescript hook for save as web archive jsg OmniWeb Feature Requests 0 2006-11-15 11:06 AM
Applescript to save and export as pdf brab OmniGraffle General 0 2006-08-10 12:20 AM


All times are GMT -8. The time now is 03:06 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.