Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux - Image files are overwritten with just a few images #66

Open
hasidima opened this issue May 1, 2022 · 12 comments
Open

Linux - Image files are overwritten with just a few images #66

hasidima opened this issue May 1, 2022 · 12 comments

Comments

@hasidima
Copy link

hasidima commented May 1, 2022

Hi

I was able to successfully convert .enex file to md files with links but the md files had the links to the same few images, although I had a lot of images in my .enex file.

The program seems to import image1, image2, image3 from one note, then export images for another note and named them also image1, image2, etc. effectively overwriting the previous images. Thus, I have different md files with the same images in all of them.

Please suggest how to resolve this issue.

Regards,
Dmitry

@wormi4ok
Copy link
Owner

wormi4ok commented May 1, 2022

Hey Dmitry,

To work around this issue I can suggest using --folders flag to save every note in a separate folder with an isolated images/ folder.

Let me know if it helps. Meanwhile, I'll try to ensure unique names for images in the next release.

@hasidima
Copy link
Author

hasidima commented May 1, 2022 via email

@elzik
Copy link

elzik commented Dec 14, 2022

Is this something that is still planned? I have the same issue and I'd really prefer not to put every note in a separate folder.

Thanks

@EnidanBri
Copy link

EnidanBri commented Dec 15, 2022

I have the same issue, and I also would prefer not to have every note in a separate folder.
The issue is not only with images, but with all attachments. Two (or more) attachments with the name "scan.pdf" also overwrite each other.

@EnidanBri
Copy link

EnidanBri commented Dec 15, 2022

I do not want to draw people away from your solution, but I found akosbalasko / yarle which has the same intention, but more configuration options.
It does rename the files both in the reference in the MD and the file itself in case the attachments have the same name.
Maybe you could join forces?

@m11751
Copy link

m11751 commented Jun 10, 2023

I want to ask a question: When I input ">evernote2md.exe --folders D:\enex_data\test.enex D:\enex_data" , I got ever different name folder and same md name : readme.md, I want to fix the md file name with different name, how can I do or you can fix this code, thank you very much !

@wormi4ok
Copy link
Owner

Hey @m11751 ! I can offer two possible solutions:

  1. The title of the file is hardcoded here and not configurable for now. But since the code is open, you can clone this project, change one line (You would need go installed) and then run go build-o evernote2md.exe to build a your custom version)

  2. A Powershell script like this should do the trick and rename all README.md files to new_name.md. Unfortunately I do not have a Windows machine to test it, so please - use it on your own risk.

forfiles /S /M "README.md" /C "cmd /c rename @file new_name.md"

@StanislavMayorov
Copy link

Hi @wormi4ok. I reproduced the same bug in the latest version (0.19.0). I exported about 1000 notes successfully, but several notes have the same images.
1-4 notes have the same image from note-4. debug logs:

2023/12/07 23:18:25 [DEBUG] Saving file ./temp/note-1.md
2023/12/07 23:18:25 [DEBUG] Saving attachment temp/image/Snapshot.png

2023/12/07 23:18:25 [DEBUG] Saving file ./temp/note-2.md
2023/12/07 23:18:25 [DEBUG] Saving attachment temp/image/Snapshot.png
2023/12/07 23:18:25 [DEBUG] Saving attachment temp/image/Snapshot-1.png

2023/12/07 23:18:35 [DEBUG] Saving file ./temp/note-3.md
2023/12/07 23:18:35 [DEBUG] Saving attachment temp/image/Snapshot.png

2023/12/07 23:18:37 [DEBUG] Saving file ./temp/note-4.md
2023/12/07 23:18:37 [DEBUG] Saving attachment temp/image/Snapshot.png

@wormi4ok
Copy link
Owner

wormi4ok commented Dec 9, 2023

Hi @StanislavMayorov ! Yeah, I can confirm that the issue still persists but unfortunately, it is an architectural bug in the app - the notes are processed sequentially so attachments with the same names within one note are handled correctly, but if the attachment name collides with the name in another note - it gets overwritten.
Maybe you can suggest a good way to work around this? So far I didn't manage to find time for a big refactoring that would solve the problem...

@EnidanBri
Copy link

Hi, A quick and dirty way would be to run a counter while processing, and then rename all images to have this counter in their filename. Then they would automatically be unique.
You might have an unwanted addition to your filenames when you do this, but I think it is better than losing them.
Basically, this is what I did when I had taht problem. But I solved it outside of your tool.

@StanislavMayorov
Copy link

StanislavMayorov commented Dec 10, 2023

Hello @wormi4ok! No, I didn't find a workaround for evernote2md.
I think the easiest way is to add a couple of random characters at the end of file name to make all of them unique e.g. filename-d2fd86c3.pdf. Something like useUniqueUnknownFileNames.

@djol
Copy link

djol commented Mar 6, 2024

evernote2md is a great tool, but this is a really dangerous bug because it leads to silent data loss. As the size of an exported evernote notebook increases, so does the likelihood of a name collision between attachments in a note.

I unknowingly ran into this problem using evernote2md on Mac OS, exporting around 900 notes. It wasn't until I had moved the resulting md files into obsidian and used the new repository for a few weeks that I noticed the wrong images in the wrong notes. It took a little time to run down the cause of the bug as arising from the original evernote2md conversion.

Because attachments in evernote notes are often added by copy-pasting into the note or dragging a file/image, there tend to be a lot of automatic filenames created by evernote or the OS, often without any timestamp (ie. image_1, image_2....). Similarly images or attachments dragged in from the web also often have very simplistic names ("report.pdf") that a user has little control over. Name collision across these attachments are really common as the size of one's evernote database increases (in fact, the probability of attachment name collision (and thus data loss) is logarithmic in nature as the number of notes increases).

No shade on evernote2md which is a great tool, but BE VERY CAREFUL if using this to export Evernote notebooks of size containing even a moderate number of attachments. As @wormi4ok comments above, you really must use the --folders flag or you will be burnt by this, and you may not discover the missing attachments for a long time after completing the conversion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants