You can also use listFiles(FilenameFilter filter) so that the returned
array only has what you want in it.

BTW does anyone know why there is a FileFilter and a FilenameFilter?

--- Nathan Tenney <[EMAIL PROTECTED]> wrote:
> The listFiles method give you an array of files.  That
> can tell you how many files and directories are in the
> current directory.  You would have to loop through
> that list checking each file to see if it is a file or
> directory to get an exact number.
> 
> You could loop over that array, and for each item that
> is a File, rename it.
> 
> --- rohit kuttappan <[EMAIL PROTECTED]>
> wrote:
> > Greeting all!
> > 
> > I'm trying to write a Java utility that could
> > enumerate and rename files =
> > in a specified directory.
> > Say, I have a directory called MyPictures which
> > contains .jpg & .gif =
> > files. I want to rename=20
> > all these files such that now they are 01.jpg,
> > 02.jpg, 03.gif etc.
> > 
> > I know there is a File class in the IO package that
> > will list out all =
> > the files in=20
> > a directory (but it does not tell how many files
> > there are) and there is =
> > a
> > renameTo( ) method which renames the file.=20
> > 
> > Is there a way I can find out exactly how many files
> > ther are in a =
> > directory and rename
> > them in the desired way. Please help me.=20
> > 
> > Also, could you please recomment a good book on
> > swing for beginers and / =
> > intermediate leve. Thanks in advance
> > 
> > Rohit
> > 
> > 
> > To change your JDJList options, please visit:
> > http://www.sys-con.com/java/list.cfm
> > 
> 
> 
> =====
> ----------------------------------
> Nathan Tenney
> Alumni Utah State University
> [EMAIL PROTECTED]
> ----------------------------------
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Finance - Get real-time stock quotes
> http://finance.yahoo.com
> 
> To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm


=====
James Amos Nathaniel Stauffer 
Stauffer_James 
@yahoo.com 
Spam food: [EMAIL PROTECTED]

__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com

To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm

Reply via email to