Batch Bxc

Shell Script Uploaded Feb 16, 2026 by pagetelegram 1 views 1.83 KB
Batch Bxc
Process using BXC csv files in sub folders.
batch csv bxc
SH batch-bxc.sh
#!/bin/bash
#
# run_bxc.sh - Run Benford digit forensics analysis on all CSV files
#              found in immediate subdirectories.
#

# ── Configurable variables ──────────────────────────────────────────
DIGIT_MODE="1"            # -d : "1" for first digit, "all" for all digits
POOL_LENGTH="10000"       # -l : sample pool length
COLUMN="7"                # -c : column number to analyze
ANIM_INTERVAL="10000"     # -a : animation update interval (records)
GEN_GIF=true              # -g : generate animated GIF
SOURCE="opendata.hhs.gov" # -s : data source description
TITLE_PREFIX="HHS Digit Forensics Report" # used in the -t title string
# ────────────────────────────────────────────────────────────────────

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
RUN_DATE="$(date '+%Y-%m-%d')"
RUN_TIME="$(date '+%H:%M:%S')"

# Build the -g flag only when enabled
GIF_FLAG=""
if $GEN_GIF; then
    GIF_FLAG="-g"
fi

processed=0
skipped=0

for dir in "$SCRIPT_DIR"/*/; do
    # Find the first csv file in this subdirectory
    csv="$(find "$dir" -maxdepth 1 -name '*.csv' -print -quit 2>/dev/null)"

    if [[ -z "$csv" ]]; then
        skipped=$((skipped + 1))
        continue
    fi

    filename="$(basename "$csv")"
    title="${RUN_DATE} ${RUN_TIME} ${TITLE_PREFIX} for ${filename}"

    echo "── Processing: ${filename}"

    bxc \
        -f "$csv" \
        -d "$DIGIT_MODE" \
        -l "$POOL_LENGTH" \
        -c "$COLUMN" \
        -a "$ANIM_INTERVAL" \
        $GIF_FLAG \
        -t "$title" \
        -s "$SOURCE"

    processed=$((processed + 1))
done

echo ""
echo "Done. Processed: ${processed}  Skipped (no csv): ${skipped}"
Download SH

← Back to SH