This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

beginner project - hints needed  RSS feed

 
Rahul Sudip Bose
Ranch Hand
Posts: 637
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my knowledge : core java, CONSOLE ONLY (please tell me if this project needs more knowledge)

The details of my project - File renaming

1-Add/remove particular pattern in the name of files in a folder. Can i make the program accept any folder to do this job ?
eg.say, files are boring1, boring2 etc. replace boring with fun to get fun1, fun2 etc

2-Remove anything before OR after a desired pattern.
eg. remove anything after -2,

max payne -2005 - 3drealms -----> max payne
crysis ----> crysis
far cry -2009 -----> far cry

all advice is welcome
regards
rb
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will need to use regex and the File API.

Can i make the program accept any folder to do this job ?

I don't see why not.
In pseudo code
1) Accept a file name
2) Check if its a folder
3) Iterate folder contents to identify individual files
4) Check if the file name fits the filter criteria
5) Rename file if it passes filter
 
Rahul Sudip Bose
Ranch Hand
Posts: 637
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to perform point 2.
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.io.File has some nifty methods you can use here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!