{"id":76,"date":"2008-11-09T13:27:06","date_gmt":"2008-11-09T12:27:06","guid":{"rendered":"http:\/\/www.askthegerman.com\/?p=76"},"modified":"2023-02-13T07:37:14","modified_gmt":"2023-02-13T06:37:14","slug":"global-rename-on-unix","status":"publish","type":"post","link":"https:\/\/www.askthegerman.com\/?p=76","title":{"rendered":"Global Rename on UNIX"},"content":{"rendered":"<p>Sometimes a situation can occur in which we need to do a bulk rename of files. Thinking about a situation in which we want to rename all .html files to make them inaccessible for a while or we want to rename all downloaded photos from your camera perhaps?<\/p>\n<p>Being on Unix this can be done easily by using a simple 4 line shell script like the one below:<br \/>\n<em><\/em><\/p>\n<p><em>for a in *.html; do<br \/>\n<\/em><em>&nbsp; t=`echo $a | sed &#8216;s\/.html$\/.html.en\/&#8217;`<br \/>\n&nbsp; mv $a $t<br em=\"\">  done<\/em><\/p>\n<p>In this example we will rename all <em>.html<\/em> file to <em>.html.en<\/em> e.q. <em>index.html.en<\/em> which comes handy in case you want to add another set of webpages to your server containing and supporting a 2nd languge.<\/p>\n<p>Guess it is not really necessary to tell you that you should make a copy of your files first??<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes a situation can occur in which we need to do a bulk rename of files. Thinking about a situation in which we want to rename all .html files to make them inaccessible for a while or we want to rename all downloaded photos from your camera perhaps? Being on Unix this can be done [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,31,15],"tags":[92,94,90,91,93,263],"class_list":["post-76","post","type-post","status-publish","format-standard","hentry","category-operatingsystem","category-tipsntricks","category-unix","tag-command-line","tag-for-loop","tag-move","tag-rename","tag-shellscript","tag-unix"],"_links":{"self":[{"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=\/wp\/v2\/posts\/76","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=76"}],"version-history":[{"count":3,"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=\/wp\/v2\/posts\/76\/revisions"}],"predecessor-version":[{"id":374,"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=\/wp\/v2\/posts\/76\/revisions\/374"}],"wp:attachment":[{"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}