{"id":20,"date":"2014-05-04T13:58:53","date_gmt":"2014-05-04T12:58:53","guid":{"rendered":"http:\/\/www.mikropunto.org\/?p=20"},"modified":"2024-12-03T23:11:43","modified_gmt":"2024-12-03T22:11:43","slug":"please-translate-in-en_us-eliminar-archivos-con-caracteres-especiales","status":"publish","type":"post","link":"https:\/\/mikropunto.org\/?p=20","title":{"rendered":"Renaming files with special characters"},"content":{"rendered":"<p>There are situations in wich a file containing special characters can be created in your file system, making it hard to remove or rename them as the file manager and even the console won&#8217;t escape the name correctly. If the file was created using UTF-8 there is no problem, but if it was first named using a different character set (say, SJIS for instance) or its name is stored in a descriptor (i.e. a ZIP file), Linux won&#8217;t be able to open it.<\/p>\n<div class=\"entry-content\">\n<p>You can still get acces to it via its <a title=\"wikipedia - inode\" href=\"http:\/\/en.wikipedia.org\/wiki\/Inode\" target=\"_blank\">index node<\/a>, without using the filename.<\/p>\n<p>(\u4e00\u822c\u30b3\u30df\u30c3\u30af) [\u5927\u53cb\u514b\u6d0b] AKIRA \u7b2c01\u5dfb.zip<\/p>\n<p>This file was created using Windows. KDE understands the japanese kanji and you can rename or delete it. But when you extract its contents, the file names stored inside the ZIP file do not have any character set associated, so the filesystem does not recognize them.<\/p>\n<p>?????S?t????1_????.png<br \/>\n?????S?t????1_?-??.png<br \/>\n?????S?t????1_???-?+??.png<br \/>\n?????S?t????1_???-????.png<br \/>\n?????S?t????1_???-?-??.png<\/p>\n<p>You can use <strong>find<\/strong> to rename them.<\/p>\n<p>First, get their inode using <strong>ls -i<\/strong><\/p>\n<p>12323499 ?????S?t????1_????.png<br \/>\n12323351 ?????S?t????1_?-??.png<br \/>\n12323581 ?????S?t????1_???-?+??.png<br \/>\n12323418 ?????S?t????1_???-????.png<br \/>\n12323479 ?????S?t????1_???-?-??.png<\/p>\n<p>Then using find &#8230;<\/p>\n<pre><code>\r\n$ <strong>find . -maxdepth 1 -inum 12323499\u00a0 -exec mv '{}' .\/akira_01.png \\;<\/strong>\r\n<\/code><\/pre>\n<p>And so the file gets renamed.<\/p>\n<p>To do this for a group of files in a subdirectory we will use a counter<\/p>\n<pre><code>\r\n<strong>$ let c=0;for i in `ls *.png -i|cut -d ' ' -f1`; \\\r\ndo let c=c+1 ;  \\\r\nfind *.png -maxdepth 1 -inum $i -exec mv '{}' .\/AKIRA_01_$c.png \\;  ; \\\r\ndone<\/strong>\r\n<\/code><\/pre>\n<p>so files get their new readable name<\/p>\n<p>AKIRA_01_1.png<br \/>\nAKIRA_01_2.png<br \/>\nAKIRA_01_3.png<br \/>\nAKIRA_01_4.png<br \/>\nAKIRA_01_5.png<\/p>\n<p><strong>Note:<\/strong> you must end the mv command given by -exec with <strong>; <\/strong>before exiting the loop with <strong>;done<\/strong>. Also, it is a good practice to prepend the semicolon with a <strong>\\<\/strong> to prevent the special characters messing with the mv.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>There are situations in wich a file containing special characters can be created in your file system, making it hard to remove or rename them as the file manager and even the console won&#8217;t escape the name correctly. If the &hellip; <a href=\"https:\/\/mikropunto.org\/?p=20\">Sigue leyendo <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,2],"tags":[],"class_list":["post-20","post","type-post","status-publish","format-standard","hentry","category-english","category-gnu-linux"],"_links":{"self":[{"href":"https:\/\/mikropunto.org\/index.php?rest_route=\/wp\/v2\/posts\/20","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mikropunto.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mikropunto.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mikropunto.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mikropunto.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=20"}],"version-history":[{"count":12,"href":"https:\/\/mikropunto.org\/index.php?rest_route=\/wp\/v2\/posts\/20\/revisions"}],"predecessor-version":[{"id":81,"href":"https:\/\/mikropunto.org\/index.php?rest_route=\/wp\/v2\/posts\/20\/revisions\/81"}],"wp:attachment":[{"href":"https:\/\/mikropunto.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mikropunto.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mikropunto.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}