Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>On Linux the venerable Perl utility <a href="http://metacpan.org/pod/File::Rename" rel="nofollow noreferrer">rename</a> is friendly:</p> <pre><code>$ rename 's/^image0+//' image*.jpg </code></pre> <p>You should be aware that stripping leading zeros will ruin the sort order, that is <code>*.jpg</code> orders like:</p> <pre><code>1.jpg 10.jpg 11.jpg ... 2.jpg 20.jpg </code></pre> <p>If you want to keep the order just use</p> <pre><code>$ rename 's/^image//' image*.jpg </code></pre> <p>instead.</p> <h2>added in response to system identification</h2> <p>You can likely script it in bash alone, but it would be non-trivial and the failure cases really need to be handled correctly. Yeah, hoisting Perl onto a system is non-trivial too, but it is easy and that wheel's already been invented</p> <blockquote> <p>Fedora Core 8 Perl RPM: <a href="http://rpm.pbone.net/index.php3/stat/4/idpl/5152898/dir/fedora_8/com/perl-5.8.8-30.n0i.51.fc8.i386.rpm.html" rel="nofollow noreferrer">http://rpm.pbone.net/index.php3/stat/4/idpl/5152898/dir/fedora_8/com/perl-5.8.8-30.n0i.51.fc8.i386.rpm.html</a><br> CPAN rename: <a href="http://metacpan.org/pod/File::Rename" rel="nofollow noreferrer">http://metacpan.org/pod/File::Rename</a></p> </blockquote> <h2>added in response to silent failure</h2> <p><code>rename</code> like <code>chmod</code> will complain if you give it malformed arguments, but both are silent if what you request has no effect. For example</p> <pre><code>$ ls -l junk -rw-r--r-- 1 msw msw 0 2010-09-24 01:59 junk $ chmod 688 junk chmod: invalid mode: '688' $ chmod 644 junk # was already 644 mode, nothing happened no error $ rename 's/bob/alice/' ju*k # there was no 'bob' in 'junk' to substitute, no change, no error $ ls -l junk -rw-r--r-- 1 msw msw 0 2010-09-24 01:59 junk $ rename 's/un/ac/' j*k # but there is an 'un' in 'junk', change it $ ls -l j*k -rw-r--r-- 1 msw msw 0 2010-09-24 01:59 jack </code></pre> <p>You can make <code>rename</code> less silent:</p> <pre><code>$ rename --verbose 's/ac/er/' j*k jack renamed as jerk $ rename --verbose 's/ac/er/' j*k # nothing to rename $ </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload