[OOZY] Renaming more than 200 pics
Dave Carrigan
dave at rudedog.org
Mon May 8 13:48:24 UTC 2006
On Sunday 07 May 2006 11:58, OOzy Pal wrote:
> Thank you; it worked. Now the names also contains "(" and ")" for
> example, a name of file is like:
> 20051030-Layan-(2).jpg
> as you can see the dashes is OK. Now, I want to remove "(" and ")"
> because linux will also put a backslash b4 the "(". Moreover, if the
> number is one digit I want to add a leading 0 so the name becomes
> 20051030-Layan-02.jpg.
To change spaces to dashes:
rename 's/ /-/g' *.jpg
To change the (2) to -02:
rename 's/\((\d+)\)/sprintf("-%02d", $1)/e' *.jpg
You could do it all in one line:
rename 's/ /-/g; s/\((\d+)\)/sprintf("-%02d", $1)/e' *.jpg
Use rename -n if you want to see what will happen without it actually doing
anything.
p.s., Linux is not putting backslashes in the names. Your shell is doing that
as a convenience for you when it does tab-completion.
--
Dave Carrigan
Seattle, WA, USA
dave at rudedog.org | http://www.rudedog.org/
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL-Postfix
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20060508/21329c7c/attachment.sig>
More information about the ubuntu-users
mailing list