renaming sub dirs problem


I have asked similiar question before, but now I am working on renaming all sub dirs and I am testing the following code, but it renames only one sub dir.
          File parentDir = new File(dir.getParentFile().getParentFile().getParentFile().toString());      
          File[] dirs = parentDir.listFiles();  
          //for (int i = 0; i < dirs.length; i++) {
          System.out.println("dirs[0]: " + dirs[0].toString());
          File oldDir = new File(dirs[0].toString());
          System.out.println("*****oldDir " + oldDir.toString());
          File newDir = new File(dirs[0].getParentFile().toString()+"\\"+"SBJ_"+getSubjectID());
          System.out.println("*****newDir  " + newDir.toString());
                  boolean success = oldDir.renameTo(newDir);
                     if (!success)
                           System.out.println("The first renaming was not successful");
                System.out.println("dirs[1]: " + dirs[1].toString());
                File oldDir1 = new File(dirs[1].toString());
                System.out.println("*****oldDir1 " + oldDir1.toString());
                File newDir1 = new File(dirs[1].getParentFile().toString()+"\\"+"SBJ_"+getSubjectID());
                System.out.println("*****newDir1  " + newDir1.toString());
                  boolean success1 = oldDir1.renameTo(newDir1);
                  if (!success1)
                     System.out.println("The second renaming was not successful");      
this is some output from print out statememts.
dirs[0]: C:\scans_test\Scans_for_Header_ext\cd_133\DirOne
*****oldDir C:\scans_test\Scans_for_Header_ext\cd_133\DirOne
*****newDir  C:\scans_test\Scans_for_Header_ext\cd_133\SBJ_null
dirs[1]: C:\scans_test\Scans_for_Header_ext\cd_133\DirTwo
*****oldDir1 C:\scans_test\Scans_for_Header_ext\cd_133\DirTwo
*****newDir1  C:\scans_test\Scans_for_Header_ext\cd_133\SBJ_null
The second renaming was not successful

any ideas why this only rename one dir?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

>>any ideas why this only rename one dir?

Because you are trying to rename to a name that already exists
>>*****newDir  C:\scans_test\Scans_for_Header_ext\cd_133\SBJ_null


>>*****newDir1  C:\scans_test\Scans_for_Header_ext\cd_133\SBJ_null

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dkim18Author Commented:
my bad...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.