daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Feb 14th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. FILES=$(find . -type f ! -path '*/vendor/*' ! -path '*.git*' )
  4.  
  5. for f in $FILES
  6. do
  7. F_CHARSET=$(file -bi $f | sed -e "s/.*[ ]charset=//")
  8.  
  9.  if [ "$F_CHARSET" != "utf-8" ] || [ "$F_CHARSET" != "binary" ] || [ "$F_CHARSET" != "unknown-8bit" ]; then
  10.    iconv -f "$F_CHARSET" -t utf-8 "$f" -o "$f.new"
  11.  
  12.    CURRENT_FILE_SIZE=$(stat -c%s "$f")
  13.    CURRENT_TMP_SIZE=$(stat -c%s "$f.new")
  14.  
  15.    if [ "$CURRENT_TMP_SIZE" -ge "$CURRENT_FILE_SIZE" ]; then
  16.      mv -f "$f.new" "$f"
  17.      echo "success \t" "$f"
  18.    fi
  19.  
  20.    if [ "$CURRENT_TMP_SIZE" -lt "$CURRENT_FILE_SIZE" ]; then
  21.     rm -f "$f.new"
  22.     echo "error \t" "$f"
  23.    fi
  24.  
  25.  fi
  26. done
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top