Last active
May 11, 2020 11:17
-
-
Save evz/4995992 to your computer and use it in GitHub Desktop.
Re encode all files in a directory tree. (requires recode)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find encoding | |
find . -type f | xargs -0 -I {} echo "{}" | xargs -I {} file -bi {} | |
# Re-encode | |
find . -type f | xargs -0 -I {} echo "{}" | xargs -I {} recode ISO-8859-1..UTF-8 {} |
Google show this answer really often, my suggestion is to avoid middle xargs and use -print0 if you call -0 xargs option:
Forward transfrom to unicode
$ find . -type f -print0 | xargs -t -0 -n 1 recode CP1251/CR-LF..UTF-8
Inverse one
$ find . -type f -print0 | xargs -t -0 -n 1 recode UTF-8..CP1251/CR-LF
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Default Windows encoding is CP1252/CR-LF