Ensure unique filename in a vault

Here is the improved version of the script:

  • Includes case-insensitive search
  • Ignores spaces during search
const duplicates = app.vault.getFiles().filter(
	(x, _, a) => 
		x.name.replace(/\s/g, '').toLowerCase().endsWith('.md') && 
		a.filter(
			(y) => y.name.replace(/\s/g, '').toLowerCase() === x.name.replace(/\s/g, '').toLowerCase()
		).length > 1
	)
	.map((x) => "[["+x.path+"]]");
dv.list(duplicates)