Skip to content

Instantly share code, notes, and snippets.

@rixtox
Created April 23, 2016 04:09
Show Gist options
  • Save rixtox/8506f18f30ec003a6824494adfae5930 to your computer and use it in GitHub Desktop.
Save rixtox/8506f18f30ec003a6824494adfae5930 to your computer and use it in GitHub Desktop.
#!/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 "{}" \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment