0

I'm trying to collate old Time Machine backups from different computers I had over the years, and want to keep only the last unique version of every file. I managed to do that using ls -d 20* | while read dir; do find "$dir" -type f -links +1 -exec rm "{}" \; done, and that worked like charm (took a while though).

The problem is that there are many linked directories, so I still have loads of duplicates because of them, and I can't find any information anywhere about how to unlink directories. For example:

iMac:ETH Mac root# stat -f "%i %N" */"HDD/Users/etolnay/.macports/opt/local/var/macports/sources/rsync.macports.org/release/ports/net/ctorrent"
21569569 2012-02-20-143022/HDD/Users/etolnay/.macports/opt/local/var/macports/sources/rsync.macports.org/release/ports/net/ctorrent
21569569 2012-03-02-054540/HDD/Users/etolnay/.macports/opt/local/var/macports/sources/rsync.macports.org/release/ports/net/ctorrent
23843405 2012-04-06-061205/HDD/Users/etolnay/.macports/opt/local/var/macports/sources/rsync.macports.org/release/ports/net/ctorrent
23843405 2012-04-13-134054/HDD/Users/etolnay/.macports/opt/local/var/macports/sources/rsync.macports.org/release/ports/net/ctorrent

There are two versions of the folder above, stored for two dates in each case. I want to delete the 2012-02-20-143022 and the 2012-04-06-061205 leaving the others. I could only do this by unlinking these directories, but unlink doesn't work on directories, and neither does gunlink from GNU CoreUtils in Homebrew, as suggested by https://superuser.com/a/557425/490956.

How can I unlink those two directories and leave only their latest entry?

0 Answers0