[Gllug] Changing case on filenames
Robert McKay
robert at mckay.com
Thu Mar 7 07:37:49 UTC 2002
On Wed, 6 Mar 2002 mriscott at yahoo.co.uk wrote:
> > > -----Original Message-----
> > > From: Chris Ball [mailto:chris at void.printf.net]
> > >
> > > #!perl -w
> > > opendir(DIR, "/path/to/dir");
> > > @files = readdir(DIR);
> > >
> > > foreach $file (@files) {
> > > rename($file, (lc $file));
> > > }
> >
> > It does but only if you are in the directory with the files. Can someone
> > tell me why this is as I cannot figure out why you have to be in the same
> > directory if you have already opened it in the script or am I doing
> > something wrong.
>
> Because you are using the filename only in the rename bit.
>
> ie. you are effectively doing:
>
> $ ls /path/to/dir/
>
> HELLO
> GOODBYE
>
> $mv HELLO hello
> $mv GOODBYE goodbye
>
> Clearly the moves will only work if you're in the right dir.
You could do ls /path/to/dir/*
-Robert.
--
Gllug mailing list - Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug
More information about the GLLUG
mailing list