Add the Title to the Text Body in Scrivener

I use Scrivener for various purposes, one of them being my daily journal. Over the years I have a couple of thousand notes. I want the header of my note to be inserted into the body of the note. On the Scrivener forum, I was able to get help in the form of a KM macro that is attached to this post.

The attached Macro works more or less exactly what I want. Just the following issues

  1. I have to run it separately for each item. So, if I select 100 in the initial popup window, it still runs for the first item and stops.
  2. The Note header when it is copied into the note is marked as 1. (header) and then the rest of the items are serially named as 2, 3 etc.

Actually, even if there is some manner in which I can do the conversion for all my notes that should suffice. I have thousands of notes, running the script thousands of times is a bit of a stretch.

The link to the post on the Scrivener forum is https://forum.literatureandlatte.com/u/popcornflix

And the full thread on the Scrivener forum is Copying the note header to the body of the text - #22 by Yashodhan_Khare - Scrivener for macOS - Literature & Latte Forums

The user who has built the Macro is 'Popcornflix', many thanks to him for getting me till here. Further help would be appreciated.

:small_red_triangle:ScrivenerTitle Conversion.kmmacros.zip|attachment (1.9 KB)

The attached Macro works more or less exactly what I want. Just the following issues

  1. I have to run it separately for each item. So, if I select 100 in the initial popup window, it still runs for the first item and stops.
  2. The Note header when it is copied into the note is marked as 1. (header) and then the rest of the items are serially named as 2, 3 etc.

My best answers:

  1. The macro is not set up to convert the items you've highlighted. It looks like it asks you to type in a number in a dialogue box and then it will start with the highlighted item and iterate as many times as you've told it to.

You can fix this by using the Filter>Line Count action on the System Clipboard. Highlight the documents you want to convert, then tell KM to copy them to the clipboard and run the Filter>Line Count action and send the result to myItem. The rest of the Macro should work fine. You can remove the Prompt For User Input action that's making the dialogue box; you won't need it anymore.

The macro seems to stop after one iteration because it's looking for the Focus On>Binder menu. You might have better luck if you replaced that action with a keystroke of control-tab.

  1. It sounds like you have List Numbering turned on for the documents. To turn it off, you can use the list tool in Scrivener's toolbar or use the menu Format>Lists>None. I don't know if there's a global way to turn it off for all your files. If there isn't, you could add the Format>Lists>None menu to the macro, so you could turn off list numbering for each document while adding the title.
1 Like

This is very helpful indeed. How do I make the macro repeat the action? It works and I made the changes. I’ll come to the number formatting in the next step, but first it has to repeat the action for all the BINDER items. So, can you help me with that? I’ll tell you what I did. There is a repeat action in that macro, so I changed it to the number of times I required and it went on and. on 1780 times (:blush:) and did the job. Since I am learning, maybe you can enlighten me on that as well.

The formatting is a challenge in Scrivener in any case. So, how can I add that to the macro? Or rather where do I add this in the macro?

I made a separate Macro for formatting. I am attaching both the Macros here. Feel free to suggest improvements or mistakes.

:small_red_triangle:Scrivener Format Lists.kmmacros|attachment (5.0 KB)

:small_red_triangle:ScrivenerTitle Conversion.kmmacros|attachment (10.1 KB)

Lastly, are you on the Scrivener forum as well?

I'm glad you found this helpful.

The method I suggested for repeating was to add to the macro an action to copy to clipboard, and then use thee Filter action to Count Lines in the clipboard. This would count the number of items you had selected in the Binder.

The result from the Count Lines action would be put in the variable myItem, which was used as the number of repeats in the main macro.

For the list numbering, I suggested simple adding a Menu action to the repating macro that would set the numbering to none using Format>Lists>None. I'd probably put that after moving to the editor and the Command-A for select all.

Many thanks, I’ll try it out. Are you on the scrivener forum?