Find and delete notes that only contain an attachment

I’m a new Obsidian user and I’ve recently finished importing around 7,000 notes from Evernote in my vault. In my old system, I stored document files ( Excel files, pdf’s, ms word, etc ) as notes, but I don’t want them in Obsidian as I’ve switch to stored them in structured folders outside of my notes.

My present goal is to locate and delete these “document-only” notes from my Obsidian vault in the most efficient way possible.

Based on my search “path:imported/evernote /(.*.pdf)/” , I have about 2000 notes to delete. There are some other document types, but pdf’s are the majority of them.

Example , but redacted, document-only note

File: Verizon Wireless paperless billing 20160607.md
---
title: "Verizon Wireless \_paperless billing 20160607"
updated: 2016-06-12 20:27:37Z
created: 2016-06-08 04:31:57Z
author: redacted
latitude: redacted
longitude: redacted
altitude: redacted
tags:
  - account
  - correspondence
  - main
  - verizon
---

[2016-06-07_2016_06_07_22_21_53.pdf](2016-06-07_2016_06_07_22_21_53.pdf)

Things I have tried

  • Reading search criteria Search - Obsidian Help
  • Tweaking the search criteria, it’s pretty accurate but some of the notes have additional content.
  • Selecting multiple notes in the results pane so that I can delete them in a single action. That doesn’t work. It seems I have to select and delete on each note individually.
  • Searching these forums and the Web for a similar problem and solution.

My questions are these

  • Is there a way to tighten up my search to return only “document-only” notes?
  • Is there a way to delete more than one note from the search results at a time?
  • If I delete these notes another from outside of Obsidian, will that have any negative impact my vault? I assume it will have to re-index. I will probably need to use a plugin to remove orphaned attachments as discussed in another thread.

Update 1

I improved the search in Obsidian -
path:imported/evernote /---\n\n\[.*\]\(.*\.pdf\)/
has 100% legitimate matches.

But I still can’t delete more than one note at a time. So, I wrote a python script to find notes with only an attachment as content, and delete them.

1 Like

Update 2

I found an easier way. Above and to the right of the search results, there is a “copy results” button. You can click on that , select to show the full (but relative to the VAULT root ) path of each file.

I copied that into a text file in the vault root, and made a 1-liner bash for loop to delete the files in the list. I initially deleted email notes since I already have the emails in my mail application. I really did try to put everything into Evernote!

Anyway. 2700 notes files down, an indeterminate number of notes to go.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.