Search vault for duplicated files (files with the same name)

Exactly what I want

Do a vault wide search and display all the files that have exact same names.
Maybe generate a result .md file.
(Searching for same aliases could be an optional function)

Case scenario

This is mainly for debugging, as sync service bugs often produce duplicates, leading to tedious work merging them back.

Could also be useful when I forgot about an old file and created a new one with the same name unknowingly.

Workarounds

None that I can think of.

Workarounds:

For example:

find . -mindepth 1 -path .obsidian -prune -path .git -prune  -printf '%h %f\n' \
  | sort -t ' ' -k 2,2 \
  | uniq -f 1 --all-repeated=separate \
  | tr ' ' '/'

I don’t know of a plugin that checks for duplicate names, but I use this handy dataviewjs query in a callout every so often to make sure I don’t have any that I don’t want https://github.com/claremacrae/obsidian-experiments-plugin/issues/1

@trainbuffer on Discord 5 months ago Discord

2 Likes

Neat solution.

I unmarked the solution so the thread will stay open because I think it’s still a good plugin idea. :slightly_smiling_face:

Just an observation, but you probably would want to compare based on some hash of the files versus just using the file name if you’re looking for true duplicates.

For future readers, this solution has stopped working. Helps would be greatly appreciated.

It works for me.
Of course I had to activate ‘enable dataview JavaScript queries’ and ‘enable dataview JavaScript inline queries’ settings on Dataview plugin as it was asked the first time I run that script.