2 points stranger-ss | 5 comments | | HN request time: 0.633s | source

Hi HN,

I built a small command-line tool inspired by Thanos’s snap. It selects randomly exactly half the files in a directory and (optionally) deletes them.

Repo: https://github.com/soldatov-ss/thanos

PyPI: https://pypi.org/project/thanos-cli/

It’s intentionally simple — feedback is welcome.

1. d3Xt3r ◴[] No.45989818[source]
> exactly half the files in a directory

What if there are an odd number of files, does it delete half a file then?

replies(1): >>45989880 #
2. ggm ◴[] No.45989852[source]
Which of . And .. does it delete?
replies(1): >>45989888 #
3. stranger-ss ◴[] No.45989880[source]
If the number of files is odd, Thanos keeps things simple - no fractional file slicing yet

Example:

11 files -> deletes 5, keeps 6 (because 11 // 2 = 5)

1 file -> deletes 0, keeps 1

4. stranger-ss ◴[] No.45989888[source]
Thanos deletes files of the directory you’re currently standing in