List duplicated file names

Hi All,

I imported my evernote notes into my obsidian vault into separated folders so now I have notes with the same name, like: ./evernote/bank.md and ./sources/bank.md

What I’m trying to do

I would like to list the duplicated file names.
The ideal result would be a table sorted by filename and link to the occurrences

If I would use SQL then the my solution would be something like:

SELECT file.name, file.link, file.mdate, file.length
FROM full_vault
WHERE file.name in (SELECT file.name FROM full_vault GROUP BY file.name HAVING COUNT(*)>1)
ORDER BY file.name, file.link

I am opened to any other solution to make visible what should I manually merge.

Things I have tried

table
group by file.name
where length(file.path) > 1

Which doesn’t give me any result.

You’re very close, try the following:

```dataview 
TABLE rows.file.link 
GROUP BY file.name 
WHERE length(rows) > 1
```

Whenever you do a GROUP BY the individual filled are collated into a rows list, so you’ll need to change to refer to that instead of the original fields.

1 Like

Thank you very much!

I was able to develop a little bit now:

TABLE WITHOUT ID rows.file.link as File, rows.file.size as Size, rows.file.folder as Folder
GROUP BY file.name 
WHERE length(rows) > 1
FLATTEN rows

Is there a way to compare the full content? Maybe some notes are real duplicates and not just the filename matches.

You can’t compare the contents unless you switch to dataviewjs and do a little bit of coding, but I reckon that files of the same size is equal 90% of the time, so I’m not sure if it’s worth the hassle. :slight_smile:

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