Login  Register

renaming files

Posted by William O'Connell-3 on Jun 04, 2008; 7:07pm
URL: http://imagej.273.s1.nabble.com/renaming-files-tp3696045.html

 This is a bit off-topic,  but I wonder if anyone has experience using the
File.renameTo command. T'll typically be renaming 20 or so files at a time.
Maybe 80% of renames will be successful. Multiple attempts will not change
the outcome. For a particular file, either the rename will succeed or it
won't.  Renames that fail are usually fo files of several megabytes, large
by my standards. Here's some of the code:

            FileInfo fi = imp.getOriginalFileInfo();
            String oldName = fi.directory + fi.fileName;
            File oldFile = new File(oldName);
.....
            String title = patientID + sep + view + sep + acqDate;
            String newName = fi.directory + title + selected_file_ext;
               boolean renamed = oldFile.renameTo(new File(newName));
               IJ.wait(100);
               if(!renamed)
               IJ.log(oldFile.getName() + " ==> " + title + ": renamed? = "
+ renamed);