<commit_before>#!/bin/env bash

extension=""
outputfile=""
outputDir="convertedMP3s"
output=""


if ! [ -d $outputDir ]; then
  mkdir $outputDir
fi

function cleanup() {
  echo -en "\ncatched SIGINT, remove $output"
  rm $output
}



trap cleanup INT

OLDIFS=$IFS
IFS=$(echo -en "\n\b")
for file in $(find .); do
  outputfile=${file%.*}
  output="$outputDir/$outputfile.mp3"
  echo $outputfile
  if [ -f "$file" ] && ! [ -e "$output" ]; then
    extension=${file##*.}
    if [ "$extension" = mp4 ] \
      || [ "$extension" = mkv ]	\
      || [ "$extension" = flv ]; then
    echo "converting - $file to mp3"
    ffmpeg -i "$file" -acodec mp3 -vn "$output"
    fi
  else
    echo "SKIPPING - $outputfile already exists or not a file"
  fi
done
IFS=$OLDIFS<commit_msg>Refactor script to use entry point and functions<commit_after>#!/bin/env bash
usage() {
  cat >&2 << EOF
Usage:	${0##*/} [OPTIONS] target destination
  
OPTIONS:
  -h			  help
  option1		  description
EOF
}
main() {
  echo "Script template"

  local -r optlist="abcdefgh"
  while getopts $optlist opt; do
    case $opt in
      a)
	;;
      b)
	;;
      *)
	usage
	;;
    esac
  done
  shift $((OPTIND - 1))
  if [[ -z $1 ]]; then
    usage
    exit 1
  fi
  extension=""
  outputfile=""
  outputDir="convertedMP3s"
  output=""


  if ! [ -d $outputDir ]; then
    mkdir $outputDir
  fi

  trap cleanup SIGINT SIGTERM SIGKILL EXIT

  OLDIFS=$IFS
  IFS=$(echo -en "\n\b")
  for file in $(find .); do
    outputfile=${file%.*}
    output="$outputDir/$outputfile.mp3"
    echo $outputfile
    if [ -f "$file" ] && ! [ -e "$output" ]; then
      extension=${file##*.}
      if [ "$extension" = mp4 ] \
        || [ "$extension" = mkv ]	\
        || [ "$extension" = flv ]; then
      echo "converting - $file to mp3"
      ffmpeg -i "$file" -acodec mp3 -vn "$output"
      fi
    else
      echo "SKIPPING - $outputfile already exists or not a file"
    fi
  done
  IFS=$OLDIFS
}
cleanup() {
  trap - SIGINT SIGTERM SIGKILL EXIT
  echo -en "\ncatched SIGINT, remove $output"
  rm $output
  exit 1
}
main "$@"
{'fraction_non_alphanumeric': 0.16079188797682278, 'fraction_numerical': 0.008208594881699663, 'mean_word_length': 2.5298126064735946, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '214049', 'n_tokens_mistral': 792, 'n_tokens_neox': 765, 'n_words': 222}