hope to ensure unique filename in different folder in a vault.
it means just use filename (not filepath) as NOTE ID
hope to ensure unique filename in different folder in a vault.
it means just use filename (not filepath) as NOTE ID
Is it possible now?
Please add this feature. I have many folders but my system calls for unique file names. This is an important feature for me and necessary for my workflow.
A few versions ago it was normal behavior, or am I wrong?
Why is it important?
Zettelkasten is great to crate ideas, its even better when your files have clear, unique names which you can create by yourself - for the total 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.
Based on a discussion in the discord somebody suggested a great work around. Never create new files with CMD-N use instead CMD-O, it will create a new file if the name is in use. I will change the short cut for CMD-N to CMD-O as well.
Thank you. Fortunately I do not have any duplicates. I run into this issue the first time today. I posted a solution which works for me.
Thanks for the dataview code.
for the note with the same name, do they have the same last modification time or creating time? can this information be also shown or used to sort the result?
Are there any updates on this recently?
Here is the improved version of the script:
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)