Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extractaudio:
- Usage: extractaudio archive_name (c)
- Use c as the second argument if the archive has mojibake filenames.
- Example: extractaudio RJ100000.zip
- Example: extractaudio RJ100001.zip c
- #!/usr/bin/bash
- archive=$1
- method=$2
- dirname=$(echo "$archive" | cut -f 1 -d '.') #Get the name of the archive without file extension
- mkdir $dirname
- if [ "$method" = "c" ]
- then
- LC_ALL=C 7z x -o"$dirname" $archive
- else
- 7z x -o"$dirname" $archive
- fi
- fixencoding $dirname
- convertaudio $dirname
- fixencoding:
- #!/usr/bin/bash
- dirname=$1
- convmv -f shift-jis -t utf8 --notest -r $dirname #Fix filenames. Will skip filenames that are already utf8.
- shopt -s globstar
- for txtfile in $dirname/**/*.txt; do
- currentencoding=$(file --mime-encoding "$txtfile" | cut -f 2 -d ':')
- if [ "$currentencoding" = " unknown-8bit" ] #Only convert txt files with unknown-8bit encoding. This prevents utf8 files from being corrupted.
- then
- iconv -f SHIFT-JIS -t UTF-8 "$txtfile" -o out.txt
- mv out.txt "$txtfile"
- fi
- done
- convertaudio:
- #!/usr/bin/bash
- dirname=$1
- shopt -s globstar
- for wavfile in $dirname/**/*.wav; do
- ffmpeg -i "$wavfile" -acodec libopus -b:a 128000 -vbr on -compression_level 10 "${wavfile%.wav}.ogg"
- rm "$wavfile"
- done
- for flacfile in $dirname/**/*.flac; do
- ffmpeg -i "$flacfile" -acodec libopus -b:a 128000 -vbr on -compression_level 10 "${flacfile%.flac}.ogg"
- rm "$flacfile"
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement