<story><title>Renaming files with mv without typing the name two times</title><url>https://gist.github.com/premek/6e70446cfc913d3c929d7cdbfe896fef</url></story><parent_chain><item><author>kelnos</author><text>Something like this isn&amp;#x27;t really necessary.  I do something like this (bash) all the time when I want to change a part of a filename (renames &amp;quot;foo-bar-baz.txt&amp;quot; to &amp;quot;foo-bar-quux.txt&amp;quot;):&lt;p&gt;&lt;pre&gt;&lt;code&gt;    mv foo-bar-{baz,quux}.txt
&lt;/code&gt;&lt;/pre&gt;
You can have an &amp;#x27;empty&amp;#x27; bit to add or remove something from the name (renames &amp;quot;foo-bar.txt&amp;quot; to &amp;quot;foo-bar-baz.txt&amp;quot;):&lt;p&gt;&lt;pre&gt;&lt;code&gt;    mv foo-bar{,-baz}.txt
&lt;/code&gt;&lt;/pre&gt;
That will work with pathname parts as well (as in the linked demo video) if you include them in the command.&lt;p&gt;I guess the linked script is useful if you need to do some complex edits to the filename, since you can&amp;#x27;t usefully have more than one curly-brace-group for this use case.  But in that case honestly I&amp;#x27;m fine just double-clicking the first argument to select, and then middle-clicking to paste, and then using the arrow keys to edit.</text></item></parent_chain><comment><author>naikrovek</author><text>I love&amp;#x2F;hate comments like yours.&lt;p&gt;You have technical knowledge applicable to the problem, and you share it.  I love that.&lt;p&gt;You miss an important feature of the solution shown in (I presume) your rush to demonstrate your bash knowledge: the ability to edit a filename shown, in place.  Brace expansion doesn&amp;#x27;t do that, doesn&amp;#x27;t show you the new filename &lt;i&gt;before you commit the name change&lt;/i&gt; and isn&amp;#x27;t even close to interactive.  This part is less great.&lt;p&gt;&amp;gt; Something like this isn&amp;#x27;t really necessary.&lt;p&gt;It may very well be necessary for someone else.</text></comment>
<story><title>Renaming files with mv without typing the name two times</title><url>https://gist.github.com/premek/6e70446cfc913d3c929d7cdbfe896fef</url></story><parent_chain><item><author>kelnos</author><text>Something like this isn&amp;#x27;t really necessary.  I do something like this (bash) all the time when I want to change a part of a filename (renames &amp;quot;foo-bar-baz.txt&amp;quot; to &amp;quot;foo-bar-quux.txt&amp;quot;):&lt;p&gt;&lt;pre&gt;&lt;code&gt;    mv foo-bar-{baz,quux}.txt
&lt;/code&gt;&lt;/pre&gt;
You can have an &amp;#x27;empty&amp;#x27; bit to add or remove something from the name (renames &amp;quot;foo-bar.txt&amp;quot; to &amp;quot;foo-bar-baz.txt&amp;quot;):&lt;p&gt;&lt;pre&gt;&lt;code&gt;    mv foo-bar{,-baz}.txt
&lt;/code&gt;&lt;/pre&gt;
That will work with pathname parts as well (as in the linked demo video) if you include them in the command.&lt;p&gt;I guess the linked script is useful if you need to do some complex edits to the filename, since you can&amp;#x27;t usefully have more than one curly-brace-group for this use case.  But in that case honestly I&amp;#x27;m fine just double-clicking the first argument to select, and then middle-clicking to paste, and then using the arrow keys to edit.</text></item></parent_chain><comment><author>sigwinch28</author><text>This is a technique I use often:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    mv file.name{,.bak}
    cp process.log{,.old}
&lt;/code&gt;&lt;/pre&gt;
etc.</text></comment>