Quick way to delete 'empty' imported Evernote notes

Yes sir. I’ve figured out I can probably do something with a smart group to show the attachments (which are all properly named and identical to the name of the original note, because they were all uploaded with Hazel + Applescript) but wondering if there’s a better way.

Well, as I wrote it’s easily done in AppleScript. However as you didn’t post the source of such a note I couldn’t write that script.

Try this… Unzip and double-click the .dtSmartRule to install it, noting you’ll need to target the Evernote group specifically.

Clean Evernote Imports.dtSmartRule.zip (1.3 KB)

However, I suggest running this on a duplicate with some groups and some loose files too before running it on the actual Evernote group. It should be safe since it’s looking for formatted notes with exactly one link, but it’s always best to test first. It works here as expected.

4 Likes

Sorry for the delay @pete31. They were imported using Import --> Notes from Evernote. The kind seems to be consistently Formatted Note. As such, the Document Display --> Source menu item is greyed out. Trivial example screenshot attached (I’m too new to add two screenshots!).

Maybe I’m missing something, but it seems the Smart Rule does not check whether the text contains only of one link without any other text. If that’s the case it’s not safe to use it.

1 Like
on performSmartRule(theRecords)
	tell application id "DNtp"
		repeat with theRecord in theRecords
			if (count paragraphs) of (plain text of theRecord as string) = 1 then
				set currentLocation to (parent 1 of theRecord)
				repeat with deadRecord in ((children of currentLocation) whose (type of it) is not formatted note)
					set name of deadRecord to (name of theRecord as string)
					move record deadRecord to parent 1 of currentLocation
					move record currentLocation to trash group of (database of theRecord)
				end repeat
			end if
		end repeat
	end tell
end performSmartRule
7 Likes

Gentlemen, this is absolutely splendid. Thank you so much. This is exactly what I was looking for and it will save me considerable effort.

@pete31 was right to highlight the potential risk, as occasionally there is a note which has a comment in addition to the attachment. Mr @BLUEFROG’s update helps avoid this. My only amendment was to change the paragraph count to 2 because it appears Evernote always includes a blank line before the link paragraph. (I’m sure this precise syntax can be checked for programmatically but outliers will be very rare.)

My sincere thanks for your assistance and for giving up some of your Sunday to do so.

1 Like

No problem.

My only amendment was to change the paragraph count to 2 because it appears Evernote always includes a blank line before the link paragraph. (I’m sure this precise syntax can be checked for programmatically but outliers will be very rare.)

I haven’t used Evernote in 5+ years so it’s possible I have older formatted files. Regardless, glad it’s working for you.

In practice, the line count is mysterious: sometimes it appears to be 1 but is actually 3, etc. Possibly carriage returns only? Starting conservatively with 1 and then validating those outliers is the order of the day and monumentally faster than the manual alternative.

I wonder if I might impose upon you both for one additional bit of guidance? As I attempt to arrow key through the items in a list, focus keeps switched to the body of the note rather than the list (so subsequent down arrows move the cursor through the note, rather than down the list). Is there some sort of vi-style command vs editor mode I am accidentally invoking? Otherwise it’s a lot of mouse clicking to flip through lots of notes.

Is this when selecting the formatted notes?

Yes sir

I’m also an Evernote refugee and encountered the note group with attachments (1 or more)
Why is it necessary to take any action?
I can work with these note groups

One issue I have is the tag assignment
I’m thinking tags should be assigned at the group level, not at the child level.
I’m planning to resolve this with an applescript

If I had groups containing of only an attachment and an “empty” note with only a link to that attachment I would also delete everything but the attachment, e.g. because they show up in search results and Smart Groups without adding any value.

What’s the point in keeping these?

1 Like

Feel free to keep the groups if you wish. There’s certainly no harm in having them present. :slight_smile:

1 Like

Now I’m really mystified… arrow keying through the list works fine on my MacBook (hurrah!), but automatically changes focus to the body of the selected note on my iMac (boo!). So I imagine it is a setting in DT that I have accidentally tinkered with? Thank you again for your patient assistance.

Are you showing the view/edit pane on both machines?

I’m not sure what you mean by view/edit pane, here’s what is switched on for both. On the iMac, some of the notes consistently switch into edit mode, and some don’t. I’m sorry, I’m sure this is a super basic function of my ignorance.

No worries! What kind of content is on the documents that switch focus?

@BLUEFROG thank you, this rule / script is extremely helpful! would you mind taking one additional step in the script? as opposed to @jeep in my imported folders the formatted note with the link and the actual content file often do not have the same name.

so before deleting the formatted note with the link in it, I first need to take the name of that file (obviously without the file extension) and rename the actual content file to that name and only then delete the formatted note and move the content file up.

to give an example:

before:

ThisIsTheFolder

  • ReallyCoolName.formatted note
  • NotSoCoolName.pdf

after:

  • ReallyCoolName.pdf

does that make sense?

thanks for any help or pointer you could give me…

2 Likes

Formatted Notes in all cases. It’s very odd. On the MacBook, focus stays on the list. On the iMac, focus consistently moves to the note content for some notes but not others.