Add a note about find . -type d -empty
- ID
8581c03- date
2024-06-19 16:15:23+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
8192182- message
Add a note about `find . -type d -empty`- changed files
2 files, 20 additions, 1 deletion
Changed files
README.md (1232) → README.md (2159)
diff --git a/README.md b/README.md
index 5a185d8..07e5ca7 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,26 @@ This tool looks for empty directories and deletes them.
$ emptydir
```
-More specifically, it deletes directories which are completely empty, or which only contain files/folders which I don't think are worth keeping (e.g. `.DS_Store`).
+More specifically, it deletes directories which are completely empty, or which only contain files/folders which I don't think are worth keeping (e.g. `.DS_Store` or `__pycache__`).
+
+
+
+
+
+## Why not use `find . -type d -empty -delete`?
+
+This command is the top answer on a [Unix Stack Exchange question](https://unix.stackexchange.com/a/107556/431830) about how to delete empty directories.
+
+The reason this isn't suitable is because it only deletes directories which are *completely* empty.
+But sometimes a directory can be non-empty, even if it appears empty.
+
+For example, this directory on macOS:
+
+<img src="totally_empty.png" alt="A Finder window for a folder 'totally_empty' which apparently contains no files.">
+
+I consider this directory to be empty, but it will be skipped by `find . -type d -empty -delete` because of the hidden [`.DS_Store` file](https://en.wikipedia.org/wiki/.DS_Store).
+
+This tool will delete directories which are empty or almost empty -- that is, when they only contain files or folders which I don't think are worth keeping, like `.DS_Store` or `__pycache__`.
totally_empty.png (0) → totally_empty.png (129310)
diff --git a/totally_empty.png b/totally_empty.png
new file mode 100644
index 0000000..c845504
Binary files /dev/null and b/totally_empty.png differ