ckunte.net

hkp

My current work involves a lot of reading, and I receive a ton of files from very many sources — colleagues, contractors, vendors, document systems, et al. The fact that I have instead tried listening to them in dull monotone must be a give away. Last Sunday, I sat down to list all the minor house-keeping annoyances that stop me in my tracks while working, so I could do something about them.

Here are the top five:

1. Split and scattered pdf files in a folder
2. Empty folders
3. File and folder permissions
4. Scattered LaTeX compile files
5. Pdf file sizes

I realised that I had solved these problems at one time or the other in the past, but hadn’t joined them up into a single tool belt that I could access with a simple command in one stroke. Like my backup routine before, I realised I could create a Makefile that could make it all possible.

My hkp repository is a result of that. The tool-belt is now accessible from any folder at my finger tips. Here are the available tools:

ckunte at air in ~/hkp (master)
\$ hk
usage: make --file=~/hkp/Makefile <cmd>
<cmd> available:
cmbi  combine all pdf files in the curr folder
cmbs  combine sub-folder-wise pdf files
efd   purge empty folders
ffp   apply permissions: folders (755), files (644)
plcf  purge LaTeX compile files
cmpr  compress all pdf files in the curr folder
cr    delete and recreate master git repository


Among the above, combining files proved troublesome, especially with all kinds of poorly named files. For a while I tried rename, which proved to be dangerous. After a bit of research, I found detox, which does a great job of renaming bad names into sane, parsable ones that the script can handle. While it was easier to install on the Mac via Homebrew (brew) and via Advanced Package Tool (apt) on debian, a Cygwin version proved elusive. In the end, I compiled source (on Cygwin!) to get a working binary in /usr/local/bin. detox’s kung fu is a thing to admire. When you’re not writing regular expressions — to catch a bunch of poorly named files and failing often, it feels like magic.