Onenote Command Line Interface

OneNoteCLI is a command line interface to OneNote 2016, 2012, and 2010 that allows you to automate the process of creating, deleting, and appending to OneNote pages from both the command line and from batch files.

OneNoteCLI offers the following features from the command line:

  • Create a note
  • Delete a note
  • Create a section
  • Delete a section
  • Append text to a note
  • Import a directory of text and image files

All actions return an exit code that can be detected from a Windows batch file.

Import a Directory of Text and Image Files

One of the most powerful features of OneNoteCLI is the ability to bulk import text files and images, recursively, into a OneNote workbook. With a simple command line you can import 1000’s of notes and sync them to the cloud.

Here’s an example command line to import a directory tree of text notes into an existing notebook:

OneNoteCLI.exe importfolder -n "Test Notebook" -r -d -p "c:\temp\Notes"

Where -r means recursive, and -d means create a Section per directory.

The above command line, when ran on this directory:

OneNote import directory of text files

This is a directory of text files that is to be imported into OneNote.

Will result in the following notes being created in OneNote:

OneNote with a section created per text file

You can see that each directory created a section, and each text file was imported as a note.

In addition to importing text files, OneNoteCLI imports JPG, GIF, BMP, TIF, and PNG files. Each image is imported as it’s own page with the title of the page matching the image filename.

Date and Time

OneNoteCLI uses the date and time stamp of the imported file as the date/time stamp for the created notes. This way you can maintain the integrity of your notes even when doing a mass import.

OneNote Command Line Interface

The OneNoteCLI command line follows the standard:

OneNoteCLI verb [-option "text"] [-option "text"]

The following verbs are supported:

  • importfolder
  • createnote
  • createsection
  • deletenote
  • deletesection
  • appendnote

OneNoteCLI can print a summary of the command line interface if you run it without any parameters:

Copyright c  2019
  No verb selected.
  importfolder     Import a folder
  createnote       create a note
  createsection    create a section
  deletenote       delete a note
  deletesection    delete a section
  appendnote       append to an existing note
  help             Display more information on a specific command.
  version          Display version information.

If you run OneNoteCLI with just a verb it will print the options for that verb:

C:\temp>OneNoteCLI createnote
Copyright c  2019
  Required option 'n, notebook' is missing.
  Required option 's, section' is missing.
  Required option 't, title' is missing.
  Required option 'b, body' is missing.
  -n, --notebook    Required. (Default: ) Notebook name
  -s, --section     Required. (Default: ) Section name
  -t, --title       Required. (Default: ) New note title
  -b, --body        Required. (Default: ) New note body
  -w, --wait        (Default: false) Wait for keypress
  --help            Display this help screen.
  --version         Display version information.

Create Notes With Batch Files

OneNoteCLI returns exit code 0 on success, and non-zero on fail. This allows for easy scripting of creating and deleting notes and sections, and even appending to existing notes.

Universal Command Line Interface To OneNote

OneNoteCLI provides a universal command line interface to OneNote that is scriptable. If there are more features that you need implemented let us know in the comments below and we’ll see if it’s possible to add them.


No installation is necessary, OneNoteCLI can be simply unzipped into a directory and ran from there.

There are 2 files in the zip package that need to be present to run.

  • OneNoteCLI.exe – This is the main program that runs
  • CommandLine.dll – This is an excellent command line parser for .NET

Download the zip file here: OneNoteCLI (154 kb)

Body SHA-256: 27f84714a2cf050dfc27b878031b8bfc2e4b71b031be3920ec3d21c36f6e7bf

AntiVirus Scan: Virus Total Scan Report



  • I failed to to download “” from your given link:

    It shows 404 Page Not Found, – I think it’s broken.

    Can you fix that? Thanks.

  • Hello,

    I am trying to use your tool that could suit my needs.

    I come across concerns that I go back to:
    OneNoteCLI.exe createnote -n “TEST” -s “section” -t “title” -b “Body”
    Create note: title
    ERR: That notebook does not exist: TEST

    In the createnote function, would the -p parameter be useful to define the location of the new note be create?

    • The “createnote” function does not have the ability to create a notebook. You need to make sure that the notebook already exists. Also, OneNote is case sensitive, so if you want to use “TEST” then make sure that your notebook is actually called “TEST”.

  • And thank you for thinking of this tool that can serve a few people

  • Hi,

    thank you for OneNote CLI. Do you have any plans to extend the functionality to listing existing entries and reading the contents of an entry?

    Have a very nice day.

  • I would love for this to work. I created a notebook called “Test” and then ran an import and got “ERR: That notebook does not exist: Test”.

    I am using Office 365 and I have both work and personal OneDrive accounts set up, and both accounts with multiple notebooks from each open in OneNote.

  • Love it so far
    is there more documentation on the commands that can be used?

    things i am looking for so far:
    – how to indicate destinations should be in a heirarchy path within a notebook (when adding or appending)
    – i.e. notebook > sectiongroup > sectiongroup > section > page

    – Also when appending in particularly, i dont want to append with just text, but most often would be from clipboard if possible


    • There is currently not a way to create what OneNote calls “groups”. I have managed to get the grouped folders to create, but I have not been able to create a note under the group yet. I’ll work on it some more.

    • Append or insert from clipboard is a great idea, and I’ll add it to the next version.

  • Your app was fantastic, a huge time saver. Thanks so much.

  • I have all of my notes stored in OneDrive. This tool does not seem to know where my notebooks are. Is it possible to use a path or point to the correct directory for my notebooks?

    • Mine too, but I have the “real” version of OneNote 2016 installed, not the Win10 store version, so it is able to work with the notebooks through that version. I suspect if you install the full version of OneNote it will work with your online notes.

      • I have the 2016 version installed from I’ve tried creating notebooks in the default USERPROFILE\Documents\Onenote Notebooks folder, and also directly in the USERPROFILE\OneDriveLocation\Onenote Notebooks folder and no matter where I try to create a notebook, the tool always says ERR: That notebook does not exist:TestFolder

        For reference, I’m using the command importfolder

        What path is the application expecting for the notebook?

        • >> What path is the application expecting for the notebook?

          My tool does not take paths into consideration, it asks OneNote behind the scenes to do things. In my personal case my notes are not stored locally, they are in OneDrive. And if I search my hard drive for my notebooks all I can find are files that end in .url and link to OneNote online.

          Can you copy/paste your command here so I can test it on my machine.

          Remember that OneNote is case sensitive, so be sure that the notebook is really named “TestFolder” and note “Test Folder” or “Test folder” or “Testfolder”.

          Also, try running the “createnote” and “createsection” commands and see what happens.

          • Oh I feel dumb. I realized that I was running the command in an elevated administrator command prompt. So the application was looking in the administrator account for the Notebook…which didn’t exist. Changed to a regular non-elevated command prompt and it worked right away.

          • Glad you figured it out. Thanks for posting the update; I’m sure it will help others.

  • No problem. I don’t suppose there’s any chance that the tools used to create this interface for OneNote could be applied to make a similar tool for Outlook, is there? Would love a simplified way to extract Notes out of Outlook into Text files…or even straight into a OneNote Notebook!

    • That’s possible, I already have some Outlook tools that I’ve written that extract messages and do things with them. It shouldn’t be too hard to tie them together.

      How should it work? I assume that the subject becomes the title of the note, but what about selecting which email messages to import? How about import all messages from an outlook folder into a section?

      Or it’s possible to use files as an intermediary step: export all messages in an Outlook folder to files, then run the OneNoteCLI import on that folder of files into a section.

      • Jason, sorry for the delay, I just about forgot about it! So what I’m working on is pulling all Outlook Notes out of a folder (I would presume the Notes folder, but it might be helpful to choose/specify) – but yes, pull all of the notes and use the subject as the name, and dump into OneNote section.

        I’ve tried some things with macros to accomplish this, outputting to text files, and then using the OneNoteCLI to import them, but the macro route is causing issues with notes that have a really long subject causing file path length issues. If the macro I have might help you with your Outlook tool, I can post it

  • Tool works great, but It fails with below error if OneNote is Open

    C:\tools\OneNoteCLI>OneNoteCLI.exe createnote -n Filer -s “Quick Notes” -t “A sample note3” -b “the body of the another text lets see”

    Create note: A sample note3
    Unhandled Exception: System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {D7FAC39E-7FF1-49AA-98CF-A1DDD316337E} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
    at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType objectType)
    at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType serverType)
    at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj)
    at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
    at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
    at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
    at System.Activator.CreateInstance(Type type, Boolean nonPublic)
    at System.Activator.CreateInstance(Type type)
    at gByTkmHVAcRhmRB3jk.RfjZhYNZUSD7dgojdx.tMNiH1HyX1EqgQPk411(Type )
    at gByTkmHVAcRhmRB3jk.RfjZhYNZUSD7dgojdx..ctor()
    at T4b94rCAjUGwKufifC.vLbHbVURKAN7XyFLrt.silct7ZjOT(aZ7LGpqqLtA42IeVCA )
    at T4b94rCAjUGwKufifC.vLbHbVURKAN7XyFLrt.G8vc4kHHao(aZ7LGpqqLtA42IeVCA )
    at CommandLine.ParserResultExtensions.MapResult[T1,T2,T3,T4,T5,T6,TResult](ParserResult`1 result, Func`2 parsedFunc1, Func`2 parsedFunc2, Func`2 parsedFunc3, Func`2 parsedFunc4, Func`2 parsedFunc5, Func`2 parsedFunc6, Func`2 notParsedFunc)
    at T4b94rCAjUGwKufifC.vLbHbVURKAN7XyFLrt.bT5cLqIFBw(String[] )
    at Yepn4wFD9WDkQU2eM2.NULi5J5V3HNtaiK7wa.xNIcXUGSJ(String[] )

    • Is it possible that you are running OneNote as a different user than OneNoteCLI? Perhaps UAC has elevated access in OneNote?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.