Renaming Files on Hoary

Tony Arnold tony.arnold at manchester.ac.uk
Tue Jun 14 22:09:30 BST 2005


Ed,

On Tue, 2005-06-14 at 14:57 -0400, Ed Fletcher wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi All:
> 
> My camera saves all picture files as .JPG for some reason.  I usually do
> a bulk rename in each directory to get the extension into lowercase, ie:
> .jpg.  However on some pictures that I copied via scp from my server at
> home, I get this error:
> 
> $ rename P1140111.JPG P1140111.jpg
> Bareword "P1140111" not allowed while "strict subs" in use at (eval 1)
> line 1.
> Bareword "JPG" not allowed while "strict subs" in use at (eval 1) line 1.
> $

Why not just use the mv command rather than a perl script? Of course, if
you have a large number of such files to rename, then the perl script
may be better, I usually do something like this:

find . -name '*.JPG' -exec mv {} `cat {} | sed -e 's/\.JPG/.jpg/'` \;

The above will rename all .JPG files to .jpg files in the current and
all its sub-directories.

But maybe I'm old fashioned:-)

Regards,
Tony.
-- 
Tony Arnold, IT Security Coordinator, University of Manchester,
IT Services Division, Kilburn Building, Oxford Road, Manchester M13 9PL.
T: +44 (0)161 275 6093, F: +44 (0)870 136 1004, M: +44 (0)773 330 0039
E: tony.arnold at manchester.ac.uk, H: http://www.man.ac.uk/Tony.Arnold




More information about the ubuntu-users mailing list