Closed andreas-vester closed 6 years ago
It's possible. I'll look into it.
I've uploaded a new version which should resolve the issue. Please, test it.
This version extracted more notes from my notebook than before. It seems to handle identical file names correctly. I saw some PDF docs with numbers attached, such as text.pdf, text_1.pdf, text_1_2.pdf and so on. However, it didn't finish correctly. I get an error. So far, I didn't changed any options inside the script.
c:\tmp>python nsx2md.py
Found pandoc 2.3.1
Converting notebook "Family"
Traceback (most recent call last):
File "nsx2md.py", line 98, in
I've uploaded fixed version. Seems to work correctly on my Win 7 test VM. Please, test.
It may work, but I wasn't able to completely test it, yet. I encountered another "issue". Given the attachment contains some kind of special character, the script fails to finish. For example, I had notes with attachments conatining characters such as '*' and "" (quotation marks). I guess there are more special characters that will lead to failure.
Maybe it makes sense to check whether the attachment has a valid file name. If not, skip the attachment and print a list at the end with all failing files. One could then decide whether the note is important enough in order to change it in Note Station and start the export process again.
I will continue testing tomorrow.
I've uploaded the version with extra path safety for all directories or files created by script. It won't skip anything but make paths safe by replacing characters Windows doesn't like.
I think the script now converted all my notes, but I'm not 100% sure. The script didn't finish with the correct success message. This might be due to the fact that I had some notes that contains a comma (,) in the title. I will change the respective titles and start the export again. I will let you know if this solves the issue. However, don't expect an answer during the next 48 hours.
Here's the message the script finally printed.
Traceback (most recent call last):
File "nsx2md.py", line 111, in
Edit:
I changed the following settings in the script to TRUE. However, the result is exactly the same.
convert_spaces_in_links = True # Replace spaces in links with '%20' force_windows_filename_limitations = True
Comma should be no problem. Looks like some of your notes have no title
attribute. I thought that this attribute is always present and haven't made a fallback. I've implemented one now and updated the script.
Aah, well that's probably true. Maybe some notes are just completely empty, i.e. created by mistake and have never been deleted.
I quickly checked your latest version. The export is now properly working. 👍
Converted 4 notebooks and 2489 out of 2489 notes. Press Enter to quit...
Great! I don't use Note Station myself, and your notebooks are very good test suite for the script. I'll close this issue and move to QON import script.
Getting the correct links/attachments is more pressing on my side compared to the QON script (if I may express a priority wish ;-) ). Also, before moving to QON, I would like to see if there is some kind of import solution possible for Joplin. I read something about a Joplin terminal. However, I haven't used it so far. Thanks for your good work!
I'll see what I can do about Joplin after I'll fix the links. ;-)
The script delivers an error if two notes have attachments, which have identical filenames.
The error message reads as follows:
Traceback (most recent call last): File "nsx2md.py", line 119, in <module> '{}/{}/{}'.format(notebook_title, media_dir, name)) FileExistsError: [WinError 183] Eine Datei kann nicht erstellt werden, wenn sie bereits vorhanden ist:
Would it be possible to change the code in a way that it attaches increasing numbers to filenames if they already exist?