{"id":1174,"date":"2020-05-24T20:32:35","date_gmt":"2020-05-25T04:32:35","guid":{"rendered":"https:\/\/accretiondisc.com\/blog\/?p=1174"},"modified":"2020-05-24T20:32:35","modified_gmt":"2020-05-25T04:32:35","slug":"file-renaming-tools","status":"publish","type":"post","link":"https:\/\/accretiondisc.com\/blog\/2020\/05\/24\/file-renaming-tools\/","title":{"rendered":"File renaming tools"},"content":{"rendered":"\n<p>Long ago, I wrote a utility (<em>brename<\/em>) that renames a set of files based on a supplied pattern. (Imagine you had an arbitrary set of JPEGs and you wanted to pretend they all came from a digital camera with names like <em>IMG_0001<\/em>, <em>IMG_0002<\/em>, etc. &#8211; that&#8217;s my favorite use case for <em>brename<\/em>. It&#8217;s really more of a re-<em>numbering<\/em> than a renaming tool.)<\/p>\n\n\n\n<p>I also have a tool I call <em>pmv<\/em> (an alias for Larry Wall&#8217;s perl <em>rename<\/em> tool (version 3.0.1.2 from August of 1990, which was something like <a href=\"https:\/\/gist.github.com\/itspriddle\/315173\">this &#8220;fork&#8221; of version 4.2 I found here<\/a>)). I use <em>pmv<\/em> when what I want to do is more complicated than <em>brename<\/em> will permit. (Interestingly, the version of perl rename I use will force filename case changes on Macs, which like to pretend that <em>ABC.txt<\/em> and <em>abc.txt<\/em> aren&#8217;t different names, while the newer version won&#8217;t.)<\/p>\n\n\n\n<p>But I recently stumbled across also <a href=\"http:\/\/manpages.ubuntu.com\/manpages\/bionic\/man1\/mmv.1.html\">mmv<\/a>. It&#8217;s like the perl rename tool but with error checking beforehand. The downside is that you can&#8217;t (easily?) limit the application of your pattern to some set of files. It&#8217;s like coming up with a rename expression <code>s\/before\/after\/<\/code> and applying it to <code>*<\/code>. (Not only that, but from reading the man page leads me to think it&#8217;s over-eager to apply that pattern not just to <code>*<\/code> but to <code>**<\/code>.)<\/p>\n\n\n\n<p>And what about <a href=\"https:\/\/www.nongnu.org\/renameutils\/\">renameutils<\/a>? I have something like its <code>qmv<\/code>. The idea is you print a list of filenames and bring it into the editor for a human to fix there. (Way back in the 80&#8217;s I used an awk command to do this; it was something like this: <\/p>\n\n\n\n<p><code>$ ls -1 *.c | awk '{printf(\"mv %20s %s\\n\",$1,$1);}' > list ; $EDITOR list<\/code><\/p>\n\n\n\n<p>The only problem with qmv is that the &#8220;plan&#8221; you create isn&#8217;t saved. Typically, the files I want to rename (especially when there&#8217;s more than a few, when qmv should shine) are backed up somewhere else, and I&#8217;d prefer to apply the same plan to the backup folder, rather than copying the (same) files there and then deleting the originals.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Long ago, I wrote a utility (brename) that renames a set of files based on a supplied pattern. (Imagine you had an arbitrary set of JPEGs and you wanted to pretend they all came from a digital camera with names like IMG_0001, IMG_0002, etc. &#8211; that&#8217;s my favorite use case for brename. It&#8217;s really more [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[52],"tags":[1098,1096,1099,1094,204,1097,1095],"class_list":["post-1174","post","type-post","status-publish","format-standard","hentry","category-technology","tag-imv","tag-larry-wall","tag-mmv","tag-mv","tag-perl","tag-qmv","tag-rename"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paRqpr-iW","_links":{"self":[{"href":"https:\/\/accretiondisc.com\/blog\/wp-json\/wp\/v2\/posts\/1174","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/accretiondisc.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/accretiondisc.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/accretiondisc.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/accretiondisc.com\/blog\/wp-json\/wp\/v2\/comments?post=1174"}],"version-history":[{"count":0,"href":"https:\/\/accretiondisc.com\/blog\/wp-json\/wp\/v2\/posts\/1174\/revisions"}],"wp:attachment":[{"href":"https:\/\/accretiondisc.com\/blog\/wp-json\/wp\/v2\/media?parent=1174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/accretiondisc.com\/blog\/wp-json\/wp\/v2\/categories?post=1174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/accretiondisc.com\/blog\/wp-json\/wp\/v2\/tags?post=1174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}