Skip to content

Instantly share code, notes, and snippets.

@rixtox
Created April 23, 2016 04:09
Show Gist options
  • Select an option

  • Save rixtox/8506f18f30ec003a6824494adfae5930 to your computer and use it in GitHub Desktop.

Select an option

Save rixtox/8506f18f30ec003a6824494adfae5930 to your computer and use it in GitHub Desktop.

Revisions

  1. rixtox created this gist Apr 23, 2016.
    31 changes: 31 additions & 0 deletions bemuse.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    #!/bin/zsh
    # ------------------------------------------------------------------
    # [Rix] Bemuse.ninja BMS Convertor
    # Converts the Japanese encoded BMS and reorder folders.
    # ------------------------------------------------------------------

    VERSION=0.1.0
    SUBJECT=bemuse
    USAGE="Usage: bemuse DIR"

    ORANGE='\033[0;33m'
    NC='\033[0m'

    # --- Option processing --------------------------------------------
    if [[ $# == 0 ]] ; then
    echo $USAGE
    exit 1;
    fi

    INPUT_DIR="$1"

    find "$INPUT_DIR" -maxdepth 1 -type f -name "*.bme" \
    -exec printf "Processing ${ORANGE}{}${NC}\n" \; \
    -exec sh -c 'iconv -f CP932 -t UTF-8 "{}" | sed -e '\''s/^\(\#WAV[[:alnum:]]\+\)[[:space:]]*.*[\\\/]\([^\\\/]\+\.[[:alnum:]]\+\)$/\1 \2/gmi'\'' | tee "{}" &> /dev/null ' \;

    printf "${ORANGE}Moving files...${NC}\n"
    mv -f "$INPUT_DIR"/*/* "$INPUT_DIR"/

    find "$INPUT_DIR"/* -maxdepth 0 -type d \
    -exec printf "Deleting folder ${ORANGE}{}${NC}\n" \; \
    -exec rm -rf "{}" \;