The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniOutliner 3 for Mac (http://forums.omnigroup.com/forumdisplay.php?f=9)
-   -   Applescript save? (http://forums.omnigroup.com/showthread.php?t=8356)

wblj 2008-07-01 03:14 AM

Applescript save?
 
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!

DerekM 2008-07-02 10:25 AM

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")
[/CODE]

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.

wblj 2008-07-02 10:56 AM

Not exactly desirable
 
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?

DerekM 2008-07-02 11:30 AM

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.


All times are GMT -8. The time now is 07:14 AM.

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