Command-line program for batch processing

Batch

Build Status

Usage | Configuration | Options | Contributing

Command-line program for batch processing.

Batch demo

Dependencies

Installation

make build # Build bin/batch
make install # Install bin/batch and scripts into ~/.local/bin

Usage

batch

Opens a list of elements in an external editor.

Elements can be received from the argument list or stdin.

Example – Running Batch with Star Platinum, Magician’s Red, Hermit Purple, Hierophant Green, Silver Chariot and The Fool:

input.txt

Star Platinum
Magician’s Red
Hermit Purple
Hierophant Green
Silver Chariot
The Fool

Edit the file:

input.txt

star-platinum

hermit-purple

silver-chariot

After you edit and save the file, it will generate a shell script which does batch actions according to the changes you did in the file.

output.sh

# This file will be executed when you close the editor.
# Please double-check everything, clear the file to abort.

map() {
  echo map "$1" → "$2"
}
map 'Star Platinum' 'star-platinum'
map 'Hermit Purple' 'hermit-purple'
map 'Silver Chariot' 'silver-chariot'

drop() {
  echo drop "$1"
}
drop 'Magician’s Red'
drop 'Hierophant Green'
drop 'The Fool'

This shell script is opened in an editor for you to review. After you close it, it will be executed.

Configuration

batch_rename() {
  batch --map 'rename "$1" "$2"' "$@"
}

batch_convert() {
  batch --map 'convert "$1" "$2"' "$@"
}

batch_relink() {
  batch --map 'relink "$1" "$2"' "$@"
}

alias rn=batch_rename
alias cv=batch_convert
alias rl=batch_relink

Options

--pick / -p command
  Run command on unchanged elements.

--map / -m command
  Run command on modified elements.

--drop / -d command
  Run command on deleted elements.

--editor command
  Configure editor.
  If command contains spaces, command must include "${@}" (including the quotes)
  to receive the argument list.

--no-confirm
  Do not ask for confirmation.

--help / -h
  Display a help message and quit.
Github statistic:
  • 4
  • 1
  • 1
  • 0
  • 6 days ago

License:

The Unlicense

Links: