Shrink- multiply index by painless script

Hi
Do You have any ideas how to make a painless scripts for shrink- multiply index
I have many of index where I need to merge a few a small shard into one?

based on:

You need to call the shrink API from an external script/application.