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:
Will result in the following notes being created in OneNote:
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:
C:\temp>OneNoteCLI
OneNoteCLI 1.0.0.0
Copyright c 2019
ERROR(S):
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.
C:\temp></code
If you run OneNoteCLI with just a verb it will print the options for that verb:
C:\temp>OneNoteCLI createnote
OneNoteCLI 1.0.0.0
Copyright c 2019
ERROR(S):
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.
C:\temp>
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.
Installation
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: 527f84714a2cf050dfc27b878031b8bfc2e4b71b031be3920ec3d21c36f6e7bf
AntiVirus Scan: Virus Total Scan Report
If you don't already have a personal binaries directory on your computer, then this is a great opportunity to create one.
Create Your First Note
Continue reading to see how to create a OneNote page from the CLI.