←back to thread

2 points stranger-ss | 1 comments | | HN request time: 0s | 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.

Show context
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 #
1. 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