Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- #: Filename : iso2utf8
- #: Title : iso2utf8 - ISO-8859-2 to UTF-8 converter
- #: Author : "Iarmin" <[email protected]>
- #: Version : 0.9
- #: Description : Converts files from iso-8859-2 to utf-8. Skips already converted files. Creating backup.
- #: Dependency : iconv, isutf8[moreutils]
- #: Options : ./iso2utf8 <file1> <file2> <file3> ...
- #
- for f in "$@"; do
- bakf="${f}.bak"
- if [ ! -f "$f" ]; then
- echo "$f: cannot open"
- fi
- if isutf8 "$f" &> /dev/null; then
- echo "$f: already in UTF-8"
- else
- mv "$f" "$bakf"
- iconv -f iso-8859-2 -t utf-8 "$bakf" > "$f"
- if cmp "$f" "$bakf" &> /dev/null; then
- rm -f "$bakf"
- else
- echo "$f: converted"
- fi
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement