<commit_before>#!/usr/bin/env bash
set -Eeuo pipefail

# Kebab case
#
# See also:
# - https://stackoverflow.com/questions/152514

# Error if user does not have Perl rename installed.
if [[ $(rename -V | grep -c "File::Rename") -eq 0 ]]
then
    echo "This script requires Perl rename (File::Rename)."
    exit 1
fi

# Using `-f` flag here for case insensitive filesystem support (macOS).
rename -f 'y/A-Z/a-z/' *

# Convert underscores and spaces to dashes.
rename 's/[_\s]/-/g' *<commit_msg>Draft update to kebab renamer<commit_after>#!/usr/bin/env bash
set -Eeuo pipefail

# Kebab case
#
# See also:
# - https://stackoverflow.com/questions/152514
# - https://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html

# Error if user does not have Perl rename installed.
if [[ $(rename -V | grep -c "File::Rename") -eq 0 ]]
then
    echo "This script requires Perl rename (File::Rename)."
    exit 1
fi

# Set IFS so we can process files containing spaces.
ifs=$IFS
IFS=$(echo -en "\n\b")

files=($@)

# printf "%s\n" "${files[@]}"

for file in "${files[@]}"
do
    # Convert underscores and spaces to dashes.
    rename 's/[_\s]/-/g' "$file"

    # Using `-f` flag here for case insensitive filesystem support (macOS).
    # rename -f 'y/A-Z/a-z/' "$file"

    # Ensure R scripts end with capital `.R`.
    # FIXME Improve the file pattern matching here.
    # rename 's/\.r$/.R' "$file"
done

IFS=$ifs
unset -v ifs
{'fraction_non_alphanumeric': 0.1590749824807288, 'fraction_numerical': 0.011212333566923615, 'mean_word_length': 3.175438596491228, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 3, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3652616', 'n_tokens_mistral': 555, 'n_tokens_neox': 512, 'n_words': 169}