Ensure unique filename in a vault

@PitchPowerBank here’s a one-liner that will find any duplicate note names:

const duplicates = app.vault.getFiles().filter((x, _, a) => x.name.match(/\.md$/) && a.filter(y => y.name === x.name).length > 1).map(x => x.path)

You could use Dataview to display the list of files for you:

```dataviewjs
const duplicates = app.vault.getFiles()
  .filter((x, _, a) => x.name.match(/\.md$/) && a.filter(y => y.name === x.name).length > 1)
  .map(x => x.path)

dv.list(duplicates)
```

If you wanted you could put it into a Templater or other script so you can launch it from a hotkey.

1 Like