Every folder and file has doubled within my vault. Urgent help!

Things I have tried

What I’m trying to do

I was moving the vault out of iCloud to try something. I just now realised that every file doubled in my vault:
I have it backed up on iCloud, is there a way to load a backup of this file, to a previous version where it wasn’t the case? Or run some code, where it removes each file which has a duplicate title + 2 at the end. (I don’t know how to do that). Could something like this work? Really need help ASAP!

There are 800 files, I don’t imagine myself doing this by hand…

Are your files also doubled in iCloud? If not, then you could delete everything on your computer and download a new version from iCloud. If everything is also duplicated in iCloud, is there a difference in the creation dates of files and the creation dates of the copies? If that is the case, you could sort your files by creation date, which would group the copies together. That way, you can delete them more easily than having to manually select every other file.

it’s same on iCloud, your solution with date created did not work, btw, if i had obsidian sync would that be an issue for me? or would i i easily load a backup?

With Obsidian Sync, you could do the first option I described, provided that the synced vault doesn’t also have duplicates. Sync does have version history, which means that you can revert individual notes back to any point in time within the last year, but I don’t know if you can also revert your whole vault back to an earlier version. If the duplicates were created locally, then Sync would also synchronize those.

I’m not familiar with Mac myself, but I found this that might work for you: macos - how can I search for folders ending in certain characters in Finder? - Ask Different. I’m not sure if this searches your whole computer or if you can also specify to only search your vault folder, but it seems worth a try. If you fill in ‘ends with’ with 2, this would give you all folders whose names end in 2. I think that if you change ‘Kind’ from ‘Folder’ to ‘Document’ then it will show you all files with file names ending in 2. You should be able to review your search results and delete files from there.

To prevent iCloud from restoring your deleted files, turn of iCloud synchronisation before deleting anything. After cleaning up your vault, delete the version in iCloud and reupload your cleaned up vault. If you don’t want to delete your vault in iCloud before the cleaned up local vault is uploaded, upload it to another folder and then delete the iCloud vault with the duplicates in it.

Hope that works!

Use this at your own risk and MAKE A BACKUP FIRST

Open the terminal app via finder, then navigate to the vault cd "/path/to/vault" (replace accordingly).

Now the dangerous bit

find . -name '*\ 2' -exec rm -r {} \;

This deletes every file and directory, that ends with " 2" in the name (space, followed by 2) in the folder you are in, and all its subfolders.

This was my test directory before

├── bar
├── test
├── test 2
├── tmp
│   ├── bar
│   ├── foo
│   │   ├── baz
│   │   └── baz 2
│   ├── foo 2
│   │   ├── baz
│   │   └── baz 2
│   ├── test
│   └── test 2
└── tmp 2
    ├── foo
    │   └── baz
    ├── foo 2
    │   ├── baz
    │   └── baz 2
    ├── test
    └── test 2

and after

├── bar
├── test
└── tmp
    ├── bar
    ├── foo
    │   └── baz
    └── test

Be advised, that GNU find (what I’m using on linux), and BSD find (what you’re using on mac) have slight differences. It should not matter in this case, but I don’t have a mac, so I won’t try.

Good luck, and may the gods have mercy on your soul. Also do backups more regularly. Cloud sync is not a backup strategy, and now you know one of the many reasons why.

1 Like

Finding the files in the GUI like @Keos suggested is definitely the safer solution.

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