Not all notes export
Thanks for this script! I've just started using it and noticed two issues.
The first time I run the script it will export about 30 (out of 1000) notes. When I run it a second time it will export most of the notes, but it appears that if two notes have the same name it will only export one. I've manually renames many notes to solve this issue but perhaps the code could check if a file exists and add a number to an note with the same name that gets exported.
(I haven't yet figured out the issue with it just exporting a small number on the first run but I'll keep looking into it.)
Update. It seems if you have a note protected with a password the script will die when it tries to back up that note. It will export the .bearnote file but it will only contain the info.json file not the text.txt file.
When you run the script a second time it will skip the note that it failed on, probably because a file does exist already, and will then keep writing out the other notes.
Traceback (most recent call last):
File "/Users/pete/Desktop/bear_backup/./bear_backup.py", line 179, in <module>
note.zip_note()
~~~~~~~~~~~~~^^
File "/Users/pete/Desktop/bear_backup/./bear_backup.py", line 112, in zip_note
self.text_with_converted_asset_paths())
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/Users/pete/Desktop/bear_backup/./bear_backup.py", line 51, in text_with_converted_asset_paths
return re.sub(asset_re,
~~~~~~^^^^^^^^^^
lambda m: "[%s]" % (self.convert_asset_path(m[2])),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
self.text())
^^^^^^^^^^^^
File "/usr/local/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/re/__init__.py", line 208, in sub
return _compile(pattern, flags).sub(repl, string, count)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'