• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using Files

 
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have a lot of files in particular folder. say "cvsadmin". It has lot of subdirectories, which itself contains lot of files in it.
What I want to do is: The file names which has ",v" extension needs to renamed.

I know we can do this for a particular file. But my folder has lots of files like this. I can go individually.

Could any body tell me the any solution?
Waiting for your reply..
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You cant do it in a single command, if this is what you were asking.
If you are not sure, how to get a list of the all the files with a specified extension, then have a look at File.listfiles() method. This will give you a list of all immediate children of a directory. To drill down deep you can recursively process each child which is a directory.

BTW, not an advanced question.
[ June 04, 2008: Message edited by: Nitesh Kant ]
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Additionally, you can use File's renameTo method to rename the file.
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't know your context but sometimes tasks may be accomplished easier without java, e.g. on linux/unix command line:

find . -name "*,v" -exec mv \{\} \{\}.new \;

will move all "*,v" files to "*,v.new".
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic