Menu

I wrote four file tools and made sure every destructive path is defensive
📰

I wrote four file tools and made sure every destructive path is defensive

DEV Community: python·David Buchan·1 day ago
#dYhgyWYm
#devtopython#devto#dev#files#file
Reading 0:00
15s threshold

I spent five years in banking operations before writing software for a living, and the reason this tool exists is muscle memory from that time: someone asks for the files to be tidied, deduplicated, backed up or triaged, and the person who volunteers learns very quickly that most file scripts are only one careless flag away from deleting the wrong thing.

So I built python-automation-toolkit as four tools behind one CLI, standard library only, with the safety behaviour written as features and then pinned in place by tests. Twenty of them, all running against pytest tmp_path sandboxes, so the test suite itself never touches a real file.

The four tools

organize sorts a folder into subfolders by extension or modification month. duplicates finds byte-identical files and optionally removes them. backup creates timestamped zip archives with rotation and restores them. logs pulls ERROR and CRITICAL lines out of a log, counts entries per level, or greps a regex.

None of that is clever.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.