renaming files

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

renaming files

William O'Connell-3
 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 for 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);
Reply | Threaded
Open this post in threaded view
|

Re: renaming files

Citron, Bruce
See if A Better Finder Rename meets your needs.
http://www.publicspace.net/ABetterFinderRename
I¹ve been using it for years and it amazes me how easy it is to use and how
well it works.
-Bruce
Bruce A. Citron, Ph.D., Dir., Lab of Molecular Biology,  Bay Pines VA
Healthcare System, Res. & Dev. 151



On 6/6/08 12:50 , "William O'Connell" <[hidden email]> wrote:

>
>  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 for 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);