Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. extractaudio:
  2. Usage: extractaudio archive_name (c)
  3. Use c as the second argument if the archive has mojibake filenames.
  4. Example: extractaudio RJ100000.zip
  5. Example: extractaudio RJ100001.zip c
  6.  
  7. #!/usr/bin/bash
  8. archive=$1
  9. method=$2
  10.  
  11. dirname=$(echo "$archive" | cut -f 1 -d '.') #Get the name of the archive without file extension
  12. mkdir $dirname
  13.  
  14. if [ "$method" = "c" ]
  15. then
  16. LC_ALL=C 7z x -o"$dirname" $archive
  17. else
  18. 7z x -o"$dirname" $archive
  19. fi
  20.  
  21. fixencoding $dirname
  22. convertaudio $dirname
  23.  
  24.  
  25.  
  26. fixencoding:
  27. #!/usr/bin/bash
  28. dirname=$1
  29. convmv -f shift-jis -t utf8 --notest -r $dirname #Fix filenames. Will skip filenames that are already utf8.
  30.  
  31. shopt -s globstar
  32.  
  33. for txtfile in $dirname/**/*.txt; do
  34. currentencoding=$(file --mime-encoding "$txtfile" | cut -f 2 -d ':')
  35. if [ "$currentencoding" = " unknown-8bit" ] #Only convert txt files with unknown-8bit encoding. This prevents utf8 files from being corrupted.
  36. then
  37. iconv -f SHIFT-JIS -t UTF-8 "$txtfile" -o out.txt
  38. mv out.txt "$txtfile"
  39. fi
  40. done
  41.  
  42.  
  43.  
  44. convertaudio:
  45. #!/usr/bin/bash
  46.  
  47. dirname=$1
  48.  
  49. shopt -s globstar
  50.  
  51. for wavfile in $dirname/**/*.wav; do
  52. ffmpeg -i "$wavfile" -acodec libopus -b:a 128000 -vbr on -compression_level 10 "${wavfile%.wav}.ogg"
  53. rm "$wavfile"
  54. done
  55.  
  56. for flacfile in $dirname/**/*.flac; do
  57. ffmpeg -i "$flacfile" -acodec libopus -b:a 128000 -vbr on -compression_level 10 "${flacfile%.flac}.ogg"
  58. rm "$flacfile"
  59. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement