{"id":1001,"date":"2011-05-08T13:48:17","date_gmt":"2011-05-08T11:48:17","guid":{"rendered":"http:\/\/raftaman.net\/?p=1001"},"modified":"2021-05-15T11:46:40","modified_gmt":"2021-05-15T09:46:40","slug":"batch-converting-files-from-iso-8859-1-to-utf-8","status":"publish","type":"post","link":"https:\/\/possiblelossofprecision.net\/?p=1001","title":{"rendered":"Batch converting files from iso-8859-1 to utf-8"},"content":{"rendered":"<p>I&#8217;ve already posted on how to convert a single file from one encoding to another (iso-8859-1 to utf-8 in <a href=\"https:\/\/possiblelossofprecision.net\/?p=396\">this example<\/a>). But how to do it for a large amount of files, let&#8217;s say LaTeX source files for example, <strong>in one go<\/strong>?<\/p>\n<p>Here&#8217;s a little bash one-liner that could help:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nfind ~ -type f -name &quot;*.tex&quot; -exec sh -c '\r\n  f=&quot;{}&quot;\r\n  iconv --from-code=ISO-8859-1 --to-code=UTF-8 -- &quot;$f&quot; &gt; &quot;$f&quot;.tmp\r\n  mv -v -- &quot;$f&quot;.tmp &quot;$f&quot;\r\n  ' \\;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve already posted on how to convert a single file from one encoding to another (iso-8859-1 to utf-8 in this example). But how to do it for a large amount of files, let&#8217;s say LaTeX source files for example, in one go? Here&#8217;s a little bash one-liner that could help: find ~ -type f -name &quot;*.tex&quot; -exec sh -c &#8216;&#8230; <a href=\"https:\/\/possiblelossofprecision.net\/?p=1001\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[28],"class_list":["post-1001","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-bash"],"_links":{"self":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1001","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1001"}],"version-history":[{"count":4,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1001\/revisions"}],"predecessor-version":[{"id":1820,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1001\/revisions\/1820"}],"wp:attachment":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}