I have written script that does the following. It uses cbl-log program to decode several log files in binary format. cbl-log only decodes 1 file at a time, so the script decodes files in bulk. If no arguments are given, it assumes log files (with extension .cbllog) are in the current directory, and it'll output files to decoded directory. Otherwise you need to give 2 arguments. The first is the directory with all cbllog files, and the second is the output directory.
#!/usr/bin/env bash
if (( $# == 1 || $# > 2 )); then
    echo "Usage:    cbldecode"  
    echo "          cbldecode <source directory> <target directory>"
    exit 1
fi
cmd="$(command -v {./,}cbl-log | head -n1)"
if [[ -z "$cmd" ]] ; then
   echo "cbl-log should be in PATH or current directory"
   exit 1
fi   
log_dir=${1:-$PWD}
out_dir=${2:-"decoded"}
count=$(find "$log_dir" -maxdepth 1 -name "*.cbllog" | wc -l) 
if (( "$count" == 0 )); then
    echo "no cbllog files in source directory"
    exit 1
fi
if ! [[ -d "$out_dir" ]]; then
    mkdir -p "$out_dir"
elif ! [[ -w "$out_dir" ]]; then
    echo "no write permission to $out_dir"
    exit 1
fi
for path in "$log_dir"/*.cbllog; do
    file=${path//$log_dir/}
    out_file="${file%.cbllog}"
    "$cmd" logcat "$path" "$out_dir"/"$out_file"
done
While this works, I'm looking for ways to make the code more compact and optimize for speed.
