Advertisement
melnikovmaxim

BKV_transcoding_files_v2

Dec 16th, 2019
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.88 KB | None | 0 0
  1. //link https://yadi.sk/i/zRspd1C8rgKk8g
  2. #!/bin/bash
  3.  
  4. IFS=$'\n'
  5.  
  6. if [ -n "$1" ]
  7. then
  8.  
  9. for y in `find . -type d`; do
  10. txt="$y/*.txt"
  11. c="$y/*.c"
  12. h="$y/*.h"
  13. html="$y/*.html"
  14.  
  15. if [ "$1" = "koi8" ] || [ "$1" = "koi7" ] || [ "$1" = "cp1251" ] || [ "$1" = "KOI8" ] || [ "$1" = "KOI7" ] || [ "$1" = "CP1251" ]
  16. then
  17.  
  18. case "$1" in
  19. "koi8" | "KOI8")
  20.     FROM_ENCODING="KOI8" ;;
  21. "cp1251" | "CP1251")
  22.     FROM_ENCODING="CP1251" ;;
  23. "koi7" | "KOI7")
  24.     FROM_ENCODING="KOI7" ;;
  25. esac
  26.  
  27. TO_ENCODING="UTF8"
  28. for file in $c
  29. do
  30. iconv -f $FROM_ENCODING -t $TO_ENCODING $file -o $file.u
  31. done
  32. for file in $h
  33. do
  34. iconv -f $FROM_ENCODING -t $TO_ENCODING $file -o $file.u
  35. done
  36. for file in $html
  37. do
  38. iconv -f $FROM_ENCODING -t $TO_ENCODING $file -o $file.u
  39. done
  40. for file in $txt
  41. do
  42. iconv -f $FROM_ENCODING -t $TO_ENCODING $file -o $file.u
  43. done
  44. fi
  45. done
  46.  
  47. else
  48. echo "No parameters found. "
  49. fi
  50. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement