Qownnotes: Create subfolders with scripts and get the path of the current note

Created on 30 Mar 2020  路  7Comments  路  Source: pbek/QOwnNotes

I have a script which setup a new folder with some templates for new projects. I create the top level folder for the project and then execute the script.

The script should then do the following:

  1. create the first notes based on some templates -> works :heavy_check_mark:
  2. create some sub-folders, e.g. for meeting notes -> doesn't work at the moment.

To solve the problem with the sub-folders I tried to call a external script as workaround. The script looks like this:
````

!/bin/bash

dir=$(dirname "$1")
mkdir $dir/meeting\ notes
``` I can't call directly "mkdir" because the scripting API from QOwnNotes doesn't has a method to get my current folder. Instead I can just usenote.fullNoteFilePath` which gives the path including the filename of the note. Therefore it is a bit hacky at the moment but it works.

Not having a method to get the path of a note also makes it hard to use the method jumpToNoteSubFolder() if I can't hard code the sub-folder.

Therefore I think it would be great if the API would provide following additional calls:

  1. a call tho get the notes current path. Ideally two methods, one to get the full path (similar to "fullNoteFilePath" but without the filename) and one to get the relative path which can then be reused in "jumpToNoteSubFolder()"

  2. a call to create a sub-folder in the current place.

Low Feature

Most helpful comment

20.3.9

  • there now is a new property relativeNoteFileDirPath for notes in the scripting engine
  • there now is a new property createNewNoteSubFolder for mainWindow in the
    scripting engine that creates a new note subfolder in the current subfolder

All 7 comments

Thank you for your suggestion.

  1. a call tho get the notes current path. Ideally two methods, one to get the full path (similar to "fullNoteFilePath" but without the filename)

Did you try fullNoteFileDirPath
https://docs.qownnotes.org/en/latest/scripting/classes/#note

and one to get the relative path which can then be reused in "jumpToNoteSubFolder()"

there will be a relativeNoteFileDirPath in 20.3.9

20.3.9

  • there now is a new property relativeNoteFileDirPath for notes in the scripting engine
  • there now is a new property createNewNoteSubFolder for mainWindow in the
    scripting engine that creates a new note subfolder in the current subfolder

There now is a new release, could you please test it and report if it works for you?

Sounds great, I will test it as soon as the debian packages are ready :-)

Tested, everything works as expected... Thanks a lot for the quick implementation! :slightly_smiling_face:

Great, thank you for testing!

Was this page helpful?
0 / 5 - 0 ratings