{"id":62,"date":"2011-05-08T08:12:13","date_gmt":"2011-05-08T06:12:13","guid":{"rendered":"http:\/\/roysharon.com\/blog\/?p=62"},"modified":"2011-12-12T14:03:12","modified_gmt":"2011-12-12T12:03:12","slug":"batch-rename-one-liner","status":"publish","type":"post","link":"http:\/\/roysharon.com\/blog\/62","title":{"rendered":"Batch Rename One-Liner"},"content":{"rendered":"<p>Following is a simple way to perform batch renaming, using the Command line:<\/p>\n<pre>ls *.jpg | awk '{print(\"mv \"$1\" \"$1)}' | sed 's\/jpg\/jpeg\/' | \/bin\/sh<\/pre>\n<p>If you wish to see the renaming commands before they are performed (just to make sure it does what you want it to do), then simply omit the last pipe:<\/p>\n<pre>ls *.jpg | awk '{print(\"mv \"$1\" \"$1)}' | sed 's\/jpg\/jpeg\/'<\/pre>\n<p>This will show you what it is going to do, without actually doing it.<\/p>\n<p>By the way, the same technique can be used for other purposes. For example the following example copies the files foo.jpg, bar.jpg and glu.jpg to subdirectory temp:<\/p>\n<pre>echo foo,bar,glu | perl -pi -e 's\/,\/\\n\/g;s\/.+\/cp $&amp;.jpg temp\\\/\/g' | \/bin\/sh<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Following is a simple way to perform batch renaming, using the Command line: ls *.jpg | awk &#8216;{print(&#8220;mv &#8220;$1&#8221; &#8220;$1)}&#8217; | sed &#8216;s\/jpg\/jpeg\/&#8217; | \/bin\/sh If you wish to see the renaming commands before they are performed (just to make &hellip; <a href=\"http:\/\/roysharon.com\/blog\/62\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-62","post","type-post","status-publish","format-standard","hentry","category-unix-tidbits"],"_links":{"self":[{"href":"http:\/\/roysharon.com\/blog\/wp-json\/wp\/v2\/posts\/62","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/roysharon.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/roysharon.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/roysharon.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/roysharon.com\/blog\/wp-json\/wp\/v2\/comments?post=62"}],"version-history":[{"count":6,"href":"http:\/\/roysharon.com\/blog\/wp-json\/wp\/v2\/posts\/62\/revisions"}],"predecessor-version":[{"id":76,"href":"http:\/\/roysharon.com\/blog\/wp-json\/wp\/v2\/posts\/62\/revisions\/76"}],"wp:attachment":[{"href":"http:\/\/roysharon.com\/blog\/wp-json\/wp\/v2\/media?parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/roysharon.com\/blog\/wp-json\/wp\/v2\/categories?post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/roysharon.com\/blog\/wp-json\/wp\/v2\/tags?post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}