How to read a lot of backlinked notes easily?

Hello. Please can someone suggest how I can best achieve the following:

I’ve got a main note, let’s say it has the title “Bookshops”, and then I have about 120 other notes that are backlinks to it (i.e. 120 other notes, each for an individual bookshop, that all have a link to the main “Bookshops” note).

I’m now at the stage where I want to read all this material, so that I can prepare to write a book. But I’m finding it very hard to click through all these notes.

What I think would be easiest would be if there was some way I could just read all 120 notes in one big scrolling window, either inside Obsidian, or just with all the 120 backlinked notes exported to a big Word doc or PDF.

In effect, this would be like an option on the Backlinks panel for the main “Booshops” note that says “Export all”.

Please does anyone know how I can do this, so that I can actually read the 120 notes that I’ve got on this topic!

Thanks a lot. Ian.

My first idea was to do a dataview query FROM [[]] and embed all results. Haven’t tried it myself - it seems to work under certain circumstances, see this discussion.

2 Likes

Embedding is sketchy to say the least. Image might work somewhat, but I’ve never had much success on actual notes.

Another option could be to build a query to provide the links to use for inclusion by the Templater plugin. Parts of the code needed are given in the thread below.

Something similar could be used looping on a query for all notes linking to a given file, e.g. “Bookshop”. I’m not sure if I would recommend it though, as it essentially will duplicate all of those notes into a single massive note. And this will duplicate all backlinks, and everything else in those files. But in theory, it’s doable.

I only tested this embedded search briefly but it seems to work:

~~~query
"[[bookshop" /.*/
~~~

The second part is a regular expression that matches 0 or more characters. That forces the entire text of each note containing the link to appear in the search previews. Make sure you type this part second, or you may crash Obsidian. :sweat_smile:

Downsides:

  • It’ll match any link that starts with “bookshop”. This can be corrected with a fancier search.
  • The formatting is bad. Text is small, everything is highlighted, and paragraphs are presented divided from each other by lines. This can be corrected with a CSS snippet. I’ve been meaning to write (or more likely ask someone to write) one like it but haven’t gotten around to it.
2 Likes

Thanks for your replies, everyone.

I experimented with them, and in the end I decided to stick with what I know, and wrote a simple Ruby script to do it. The script only looks for a search term, so it doesn’t fully respect the Backlinks, but it’s good enough for what I personally need.

I hope it helps somebody at some point!
Ian.


# A short Ruby script to search an Obsidian database and find all files that match a search term (regex).
# Use this to see all your notes about a particular topic in one place.
# Put this script in the folder of the Obsidian vault you want to use it for.
# Example usage:
# ruby showall.rb 'bookshop'

# Setup
do_not_show = '^---$|^tags:|^aliases:' # A regex of lines to ignore and not show in the final output

# Check there is a search term
search_term = ARGV[0]
if search_term.nil? then
  puts "Please enter a search term - it is not case sensitive."
  puts "Usage: ruby showall.rb [regex to find]"
  exit
end

# Select the files (the notes) we're interested in, which contain the search term
selected_files = []
all_files_list = Dir.glob('**/*.{md}').sort_by{ |f| File.mtime(f) } # The initial ** makes it recursive over subdirectories, then sorted by file modification time
all_files_list.each{|filename|
  if File.readlines(filename).grep(/#{search_term}/i).any?  # The i makes it case-insensitive
    selected_files << filename
  end
}
total_files = selected_files.size
puts "Found #{total_files} matching files."

# Create the output
i = 1
selected_files.each{|filename|
  puts "----- #{i} of #{total_files} ----- #{filename} ----- #{File.mtime(filename).strftime('%-d %b %Y')}"
  File.foreach(filename) { |line| 
    unless line.match do_not_show then puts line end
  }
  puts ''
  i += 1
}

# Show a little summary at the end
puts '====='
puts "Found #{total_files} matching files."
1 Like

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