On Linux the venerable Perl utility rename is friendly:
$ rename 's/^image0+//' image*.jpg
You should be aware that stripping leading zeros will ruin the sort order, that is *.jpg
orders like:
1.jpg
10.jpg
11.jpg
...
2.jpg
20.jpg
If you want to keep the order just use
$ rename 's/^image//' image*.jpg
instead.
added in response to system identification
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
Fedora Core 8 Perl RPM: 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
CPAN rename: http://search.cpan.org/~rmbarker/File-Rename-0.05/
added in response to silent failure
rename
like chmod
will complain if you give it malformed arguments, but both are silent if what you request has no effect. For example
$ 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
You can make rename
less silent:
$ rename --verbose 's/ac/er/' j*k
jack renamed as jerk
$ rename --verbose 's/ac/er/' j*k # nothing to rename
$