Jump to content

Metadata lost when exporting to html


Recommended Posts

Hi all,

So what I'm trying to do is export my Evernote notes and put them into Google Drive folders as Docs files. It seems pretty simple to do because Evernote can export .html files of every note and then Google Drive can convert the .html file into a docs file when I upload. Easy! But the problem is is that the metadata is all wrong. So even though in Evernote I've got files dating back to 2012, they all appear on Google Drive as though they were created and modified on 28 June 2020. Obviously, finding things becomes a mess.

So unless someone has a better workflow, is there any way that I can retain each file's metadata when I export to .html?

Link to comment
  • Level 5*
32 minutes ago, zigzagwanderer said:

is there any way that I can retain each file's metadata when I export to .html?

I use a script on my Mac to append the metadata to the note's contents106389817_ScreenShot2020-06-28at9_04_51AM.png.da86c59380fe927a22a1f6998e788c2a.png

 

 

btw  The note's metadata is embedded in the HTML1550873119_ScreenShot2020-06-28at9_01_47AM.png.461eff17f66c6787a7bfe617b1e976f8.png

 

 

Link to comment

 

17 minutes ago, DTLow said:

I use a script on my Mac to append the metadata to the note's contents
 

Aha! I see I see. Is there a way to find this script online, or is it one you wrote yourself? 

Thank you for the point in the right direction too!

Link to comment
  • Level 5*
1 hour ago, zigzagwanderer said:

Aha! I see I see. Is there a way to find this script online, or is it one you wrote yourself? 

Just a do-it-yourself applescript

tell application "Evernote"
  set theNotes to get selection
  repeat with theNote in theNotes
	set theTitleHTML to title of theNote as string
	set thedate to modification date of theNote
	set theLink to note link of theNote
	set AppleScript's text item delimiters to "/"
	set parsedList to text items of theLink
	set noteUID to item 7 of parsedList			

	set newText to "<hr/>Metadata Start"
	set newText to newText & "<div><span style=\"color: rgb(4, 51, 255);\"><span style=\"font-size: 12px;\">Title: " & theTitleHTML & "</span></span></div>"
	set newText to newText & "<div><span style=\"color: rgb(4, 51, 255);\"><span style=\"font-size: 12px;\">"
	set newText to newText & "Updated:  ud" & my FormatDate(modification date of theNote)
	set newText to newText & "   Created: cd" & my FormatDate(creation date of theNote)
	set newText to newText & "   Subject: sd" & my FormatDate(subject date of theNote)
	set newText to newText & "<div><span style=\"color: rgb(4, 51, 255);\"><span style=\"font-size: 12px;\">"
	if reminder order of theNote is not missing value then
		set newText to newText & "Reminder: rd" & my FormatDate(reminder time of theNote)
		set newText to newText & "   Completed:  xd" & my FormatDate(reminder done time of theNote)
	end if
	set newText to newText & "<div><span style=\"color: rgb(4, 51, 255);\"><span style=\"font-size: 12px;\">"
	set newText to newText & "<div><span style=\"color: rgb(4, 51, 255);\"><span style=\"font-size: 12px;\">Notebook: " & name of notebook of theNote & "</span></span></div>"
			
	set theTags to tags of theNote
	set theTagNames to {}
	repeat with theTag in theTags
		set theTagName to name of theTag
		set end of theTagNames to theTagName
		set the theTagParent to parent of theTag
		set newText to newText & "<div><span style=\"color: rgb(4, 51, 255);\"><span style=\"font-size: 12px;\">"
		set newText to newText & "Tag_" & theTagName
		repeat while theTagParent is not missing value
			set newText to newText & " > " & name of theTagParent
			set the theTagParent to parent of theTagParent
		end repeat
		set newText to newText & "</span></span></div>"
	end repeat
			
	set newText to newText & "<div><span style=\"color: rgb(4, 51, 255);\"><span style=\"font-size: 12px;\">ID: [" & noteUID & "]</span></span></div>"
	set newText to newText & "Metadata End<hr/>"
			
	append theNote html newText
	set modification date of theNote to thedate
  end repeat		
end tell
Link to comment

I must admit I am not well versed in these kinds of things at all. Running by instinct, I made a new script in Applescript, copied and pasted your coding, and then let it run. I encountered this problem (in the gif).

What am I doing wrong?

ezgif-3-41ff74b8b28e.gif

Link to comment
  • Level 5*
16 minutes ago, zigzagwanderer said:

I encountered this problem (in the gif).

What am I doing wrong?

You're doing quite well to get things running

I missed a few details; I updated the above script

#1  Identify the notes being processed
      set theNotes to get selection
      repeat with theNote in theNotes

#2 Identify elements from the note
        set theTitleHTML to title of theNote as string
        set thedate to modification date of theNote
        set theLink to note link of theNote
        set AppleScript's text item delimiters to "/"
        set parsedList to text items of theLink
       set noteUID to item 7 of parsedList

Link to comment

Excellent! This feels like a riddle. But I encountered another error. I run it and get this 

Syntax Error: Expected “end” but found “end tell”.

So then I did a bit of Googling—I have to again note that I am an utter novice at this—but I found on some website that if I simply put "end" above "end tell" that Script Editor would accept it. It did, but then the issue became

«script» doesn’t understand the “FormatDate” message.

So I'm back where I started. Any guidance, @DTLow? Again, thank you so much, this is a huge help.

Link to comment
  • Level 5*
8 minutes ago, zigzagwanderer said:

Syntax Error: Expected “end” but found “end tell”.

We added a repeat loop, but I forgot the end repeat
Add "end repeat" before the "end tell"

>>«script» doesn’t understand the “FormatDate” message.

I didn't like the default date formatting so I created my own handler

on FormatDate(testDate)
     
if testDate is not missing value then
          
set {year:y, month:m, day:d, hours:h, minutes:min, seconds:sec} to testDate
          
set d to (text -2 thru -1 of ("0" & d as text))
          
set m to m as integer
          
set m to (text -2 thru -1 of ("0" & m as text))
          
set y to y as text
          
set h to (text -2 thru -1 of ("0" & h as text))
          
set min to (text -2 thru -1 of ("0" & min as text))
          
set sec to (text -2 thru -1 of ("0" & sec as text))
           
set returnDate to y & "-" & m & "-" & d & "-" & h & ":" & min
     
else
          
set returnDate to testDate
    
end if
     
return returnDate
     
end FormatDate

Link to comment

Thanks. So I read online that handlers need to be placed at the end of the script. I did that, and off it went! Success.

It seemed to only fiddle with one note though, not all of them. And when I exported the note I had had selected into .html, Finder still reads it as a file that was birthed a few minutes ago. The example I have here is a file that was last updated in Evernote in 2015, but Finder sees it as Today.

What have I done wrong now?

Screenshot 2020-06-28 at 19.50.11.png

Link to comment
  • Level 5*
9 minutes ago, zigzagwanderer said:

It seemed to only fiddle with one note though, not all of them.

What's your criteria for notes being processed?   
My idea was to select the notes (one or multiple)   
and use the code    set theNotes to get selection    
                                   repeat with theNote in theNotes

>>And when I exported the note I had had selected into .html, Finder still reads it as a file that was birthed a few minutes ago

I have no solution to that issue   
My scripting is used to append metadata to the note contents

 

 

Link to comment
2 minutes ago, DTLow said:

>>And when I exported the note I had had selected into .html, Finder still reads it as a file that was birthed a few minutes ago

I have no solution to that issue   
My scripting is used to append metadata to the note contents

Ah I see. My bad, I must've explained it poorly. No worries, then, but thank you for the script—I learned something anyhow.

Hopefully someone out there might know!

Link to comment
  • Level 5*
20 hours ago, zigzagwanderer said:

Metadata lost when exporting to html ... But the problem is is that the metadata is all wrong.

As I showed above, the note metadata is not lost when exporting notes

I was hoping someone had ideas for converting the metadata to useable information

I can tell you the utility I plan to use for this is Keyboard Maestro
I haven't followed up on this (I'm waiting for the Evernote Apocalypse)
My idea is to use the KM utility to
- monitor the folder for new files
- extract the note metadata
- update the file information; date created, tags, ...

Link to comment

Is the idea to get the embedded metadata inside the HTML files to reflect on the file itself? I've been Googling but not found anything that'll do the trick. I look forward to your solution, though, if you ever get round to it.

The Evernote Apocalypse has come for me, unfortunately. I still intend on using it for a few notes here and there, but by and large its incessant problems and lack of improvements have kicked me out. Making the migration to Google Drive, however, is gonna be a sad affair if all my 1000s of notes were 'created yesterday'. 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...