Querying notes in one tinderbox document and copying the found queried notes (by copy and paste) to a new tinderbox document?

Hint: the Agent results are alias and do not copy. How do you easily copy and paste these notes over to a new document?

I have a Commonplace Tinderbox document that I like to store my notes. I would like to start a new project in a new Tinderbox document with some queried notes I found very interesting. A deeper dive, if you will in a clean Tinderbox document.

I have 67 notes I wanted to start with that my Agent found. All good. I realize these are aliases and will not copy directly. My question is how do I copy the originals of this query into my new tinderbox document.

My manual solution is to right click on each one to goTo the original and copy them one at a time. Is there another more automated way?

Here is a dummy test file I included to test. In the example, let’s say I want to copy the originals of the agent query notes. How do I do that?

CopyNotesTest.tbx (106.0 KB)

Thanks in Advance
Tom

Since you’re not doing this every day, one fast route might be the following:

  1. Make a copy of your document. Call it “temporary copy”
  2. Let your agent mark all the notes it finds in a distinctive way — for example, by setting a new user attribute to true. I might do this simple using flags or badges, if I’m not using flags or badges in this document.
  3. Check to make sure all the notes you want are flagged properly.
  4. Make a container named suitcase
  5. Add the agent action $Container(original)="/suitcase";

Now, all the notes you want to copy are conveniently packed up and ready for the trip.

3 Likes

Brilliant! Thanks MarkB.
Tom

As more automated, less cut-and-paste, approach (for those desiring it) could be to use Tinderbox’s AppleScript support. I won’t head down the rabbit hole (I don’t have code) as the above seems to fit the bill, but note the latter for other thread readers.

@TomD, try this.

Objective:

As a User, I want to be able to copy alias notes over to another Tinderbox file.

Steps:

  1. Run create an agent to find notes that meet desired parameters

  2. Check $IsPackSuitcase boolean on the notes you want to copy to another file. The Agent will move the notes to the Suitcase.

  3. Copy the notes over to your new file [See Future Considerations for comment on user attributes]

  4. When you’re done copying and you’re ready to “unpack your suitcase” apply the `UnpackSuitcase” stamp.

Explanation of Functions:

The pack for travel function saves the original container of a note before it is moved to the Suitcase. The unpack suitcase function will use the $ContainerOriginal value to put the note back when you’re done copying it over to your other Tinderbox file.

The tricky part in the flow of the action code is to ensure that the agent does not apply the Suitcase $Path to the notes in the $Suitcase. This is the reason or the conditions in the function.

Condition:

  • Using V9.1

  • Aliases can’t be copied to another TBX file

  • There is no copy() or duplicate() action code as of V9.1

  • Requires the following user attributes:

    • ContainerOrginal, String type

    • IsPackSuitecase, Boolean type

  • Has fPackForTravel() function

  • Has fUnpackSuitcase function

Future Consideration:

  • User Attribute values will not copy over to the new tinderbox file when you copy notes from the suitcase. You will need to make sure that you’ve first created any User Attributes associated with your notes in the Suitcase.

  • There may be a way to create the user attributes in the other TBX file using the create attributes Apple Script.

  • Look at using Apple Script to copy notes from one Tinderbox File to Another (can model off of the TBX to DevonThink and Drafts to TBX AppleScript).

  • The original container has no $OnAdd or $OnRemove action - or not one who’s (re-)running may affect the note’s data.

  • Similarly, is any note’s movement affecting its interaction with an (agent’s) action.

  • Moved notes have no children. Or, if they do the children/descendants are expected to be part of the migrated notes.

TBX L - Copy Queried Notes to Another Doucment.tbx (169.9 KB)

Some other necessary assumption:

  • The original container has no $OnAdd or $OnRemove action - or not one who’s (re-)running may affect the note’s data.
  • Similarly, is any note’s movement affecting its interaction with an (agent’s) action.

Neither invalidates @satikusala’s idea, which I like, but are necessary considerations for more complex documents. Links, and thus link actions, should be unaffected unless the note move triggers an action that makes or breaks a link.

1 Like

Good catch.

BTW, if there was a copy( ) or duplicated( ) action code we could modify the functions to have the agent copy the notes into the Suitcase. We would not need the container piece. Once moved, the user could just delete them.

Another condition/assumption (I just tested):

  • Moved notes have no children. Or, if they do the children/descendants are expected to be part of the migrated notes.

I can add that to the above list (if agreed and if you’re not able to edit the post).

Again, I don’t see this as problematic but simply something for which the user to be aware of before ‘just’ tinkering and getting an unexpected effect. :slight_smile:

1 Like

Done.

1 Like

Totally forgot about this one.

One simple method I found helpful was/is to use the Filter/Query method with a view instead of using an agent in outline view

Steps

  1. Open the container you want in a new tab
  2. Use View/Filter
  3. Add your query
  4. Copy your original notes into a new tinderbox document

Tom

1 Like

As another example of what it takes to copy a complete tool or applet from one Tinderbox document to another, I just added a step-by-step guide to doing this with the Toolbox logging application. The new version 1b of the Toolbox file is here.

The step-by-step guide is in this note:

"/Main Document/How to add logging tools to another Document"

While this is a specific example, and not a general case, it does point out some of the issues with copying Prototypes, Hints, and Templates along with what needs to be done to activate Attributes and Stamps in the destination document.

I also recognize the utility of using AppleScript to automate aspects of this, and plan to dig into this approach as well.

If you don’t mind to use an external AS app - this line is all I need to get my basic attributes I need in each and every file ready:

createUserAttributes_db("AssignPrototype:string;DebugNote:string;DefaultPrototype:string;DoDebugLog:boolean;HeadingLevel:dictionary;SelectPrototype:dictionary;");

Then I create my global preferences file:

create("/gPreferences");
$DisplayedAttributes("/gPreferences") = "HeadingLevel;SelectPrototype;DebugNote;DoDebugLog;DefaultPrototype";
$HeadingLevel("/gPreferences") = "1:1;2:2;3:4;4:4;5:3;6:3";
$DebugNote("/gPreferences") = "/debug";
$DefaultPrototype("/gPreferences") = "pFolder";

Then I create some prototypes like:

create("/Prototypes/pFolder");
$DisplayedAttributes("/Prototypes/pFolder") = "AssignPrototype";
$OnAdd("/Prototypes/pFolder") = "setPrototypeOnAdd_db();";
$Badge("/Prototypes/pFolder") = "folder-settings-outline";
$Edict("/Prototypes/pFolder") = "if(!$IsPrototype){$AssignPrototype=$SelectPrototype(" + "'" + "/gPreferences" + "'" + ")[$Name];}";
$OnRemove("/Prototypes/pFolder") = "doArchive_db();";

and so on - all this action code lives in a stamp. So for a new file I add the hints from the TBX menu, copy two notes (the stamp and a library note with some basic functions), run the stamp once and I’m ready to go. Takes less then a minute :wink:

As an alternativ for a new file: just store a copy of a prepared file anywhere and copy this as a start if you need a new one. The above method works with existing files too.

2 Likes

@webline—Thanks for this AppleScript. I am trying it out and working on integrating it into my workflow.

You have provided a nice bridge over a hole in Tinderbox. I was playing around with the “attribute” operator and its reputed ability to set at least the default and suggested configurations for attributes, but as has been noted by @mwra in the posting on List attribute options, this feature is not working, at least not with 9.1. Hopefully, your AppleScript will let me move forward.

2 Likes