Time to read: 1 minutes.
I've been reorganizing directories across several volumes on an Ubuntu server.
This blog post documents how I used the commands I found to be most useful:
The latter two programs are not installed by default.
You can install them this way:
$ yes | sudo apt install fdupes ncdu
Display Directory Sizes
$ ncdu /directory
Find Duplicate Files
This displays duplicate files and interactively asks which duplicate files to delete.
$ fdupes -r1Sd /directory
Compare Two Folders For Missing Files
This tip was inspired by an answer on
-n option displays the names of missing files in the destination directory,
but makes no changes to the destination file system.
If that option is not specified, then the missing files are copied.
$ sync -ri --ignore-existing -n /srcDir/ /destDir
There are a few things to note:
- The first directory is the source, and it must end with a slash (/).
- The second directory is the target, and it must NOT end with a slash.
Copy Missing Files
Simply do not provide the
-n (dry run) option:
$ rsync -ri --ignore-existing /srcDir/ /destDir