snipt

Ctrl+h for KB shortcuts

Bash

Renombrar de [1-9].jpg a [01-09].jpg

for a in [1-9].jpg;do mv $a `printf %02d.%s ${a%.*} ${a##*.}`; done
https://snipt.net/embed/8812d182bee590adb4f43b998e6a54bd/
/raw/8812d182bee590adb4f43b998e6a54bd/
8812d182bee590adb4f43b998e6a54bd
bash
Bash
1
2019-07-22T11:45:54
True
False
False
/api/public/snipt/20406/
renombrar-de-1-9jpg-a-01-09jpg
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">for</span> a in <span class="o">[</span>1-9<span class="o">]</span>.jpg<span class="p">;</span><span class="k">do</span> mv <span class="nv">$a</span> <span class="sb">`</span><span class="nb">printf</span> %02d.%s <span class="si">${</span><span class="nv">a</span><span class="p">%.*</span><span class="si">}</span> <span class="si">${</span><span class="nv">a</span><span class="p">##*.</span><span class="si">}</span><span class="sb">`</span><span class="p">;</span> <span class="k">done</span> </span></pre></div> </td></tr></table>
bash, linux, rename