Batch processing with Kakoune

https://github.com/alexherbo2/batch

3 Likes

Wow, you outdone yourself this time @alexherbo2!

I’ve been using massren for a while but this is way more generic tool. Well done!

1 Like

I really like how it returns a shell file output.sh for inspecting and editing/customizing the commands and deciding when and how to actually run the script. Simple and clever.

There’s a point in the editing where you replace some filenames with numbers, remember the # register (try 8o<c-r>#).

1 Like

This idea comes from the bulkrename command of ranger.

There’s a point in the editing where you replace some filenames with numbers […]

You mean when renaming the Kizumonogatari movies?
I knew about the registers but on the moment, and for 3 files, I preferred to not think too much about having the perfect command.

Batch integration with connect.kak:

~/.config/kak/connect/commands/:batch

#!/bin/sh

map='
  rename "$1" "$2"
  :send evaluate-commands -buffer "$1" rename-buffer "$2"
'

drop='
  :send delete-buffer "$1"
'

:ls | batch --editor kak --map "$map" --drop "$drop"

Extracted from my kakrc.

It allows to rename and drop buffers from the buffer list.

Super cool and interesting tool. I was going to ask some questions, but figured out the answers while asking!

I might give this to my brother as a learning tool to help learn bash scripting.

It seems you can use kak itself to batch process files — that’s something I’ll definitely try doing at some point myself, too.

Yeah, this is such a great pattern, I really wish more stuff would follow it. Ruplacer makes a diff as the output to run or inspect (it also has a --go to just do it).