com.pixelmed.dicom
Class MoveDicomFilesIntoHierarchy

java.lang.Object
  extended by com.pixelmed.dicom.MoveDicomFilesIntoHierarchy

public class MoveDicomFilesIntoHierarchy
extends Object

This class provides a main method that recursively searches the supplied paths for DICOM files and moves them into a folder hierarchy based on their attributes.

Various static utility methods that assist in this operation are also provided, such as to create the hierarchical path name from the attributes, etc., since these may be useful in their own right.


Field Summary
protected static String defaultDuplicatesFolderNamePrefix
           
protected static String defaultHierarchicalFolderName
           
 
Constructor Summary
MoveDicomFilesIntoHierarchy()
           
 
Method Summary
static void main(String[] arg)
          Recursively search the supplied paths for DICOM files and move them into a folder hierarchy based on their attributes.
static String makeHierarchicalPathFromAttributes(AttributeList list)
          Create a folder structure based on the DICOM attributes of the form:
protected static void processFilesRecursively(File file, String suffix)
           
static boolean renameFileWithHierarchicalPathFromAttributes(File file)
          Rename a DICOM file into a folder hierarchy based on its attributes.
static boolean renameFileWithHierarchicalPathFromAttributes(File file, AttributeList list, String hierarchicalFolderName, String duplicatesFolderNamePrefix)
          Rename a DICOM file into a folder hierarchy based on its attributes that are already available.
static boolean renameFileWithHierarchicalPathFromAttributes(File file, String hierarchicalFolderName, String duplicatesFolderNamePrefix)
          Rename a DICOM file into a folder hierarchy based on its attributes.
static boolean renameFileWithHierarchicalPathFromAttributes(String fileName)
          Rename a DICOM file into a folder hierarchy based on its attributes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultHierarchicalFolderName

protected static String defaultHierarchicalFolderName

defaultDuplicatesFolderNamePrefix

protected static String defaultDuplicatesFolderNamePrefix
Constructor Detail

MoveDicomFilesIntoHierarchy

public MoveDicomFilesIntoHierarchy()
Method Detail

processFilesRecursively

protected static void processFilesRecursively(File file,
                                              String suffix)
                                       throws SecurityException,
                                              IOException,
                                              DicomException,
                                              NoSuchAlgorithmException
Throws:
SecurityException
IOException
DicomException
NoSuchAlgorithmException

makeHierarchicalPathFromAttributes

public static String makeHierarchicalPathFromAttributes(AttributeList list)

Create a folder structure based on the DICOM attributes of the form:

PatientName [PatientID]/StudyDate StudyTime [StudyID - StudyDescription]/Series SeriesNumber [Modality - Series Description]/SOPInstanceUID.dcm

If the SOPInstanceUID is missing, an empty String is returned.

Parameters:
list -

renameFileWithHierarchicalPathFromAttributes

public static boolean renameFileWithHierarchicalPathFromAttributes(File file,
                                                                   AttributeList list,
                                                                   String hierarchicalFolderName,
                                                                   String duplicatesFolderNamePrefix)
                                                            throws IOException,
                                                                   DicomException,
                                                                   NoSuchAlgorithmException

Rename a DICOM file into a folder hierarchy based on its attributes that are already available.

Creates a folder structure in the current working directory of the form:

hierarchicalFolderName/PatientName [PatientID]/StudyDate StudyTime [StudyID - StudyDescription]/Series SeriesNumber [Modality - Series Description]/SOPInstanceUID.dcm

If the destination file already exists and is identical in content, the original is removed.

If the destination file already exists and is different in content, it is not overwritten, and the duplicate is moved into a separate duplicatesFolderNamePrefix_n folder.

Parameters:
file - the DICOM file
list - the attributes of the file (already read in)
hierarchicalFolderName - where to store the renamed file
duplicatesFolderNamePrefix - where to store the renamed file if it is a non-identical duplicate of the existing file
Returns:
true if successful, false if not
Throws:
IOException
DicomException
NoSuchAlgorithmException

renameFileWithHierarchicalPathFromAttributes

public static boolean renameFileWithHierarchicalPathFromAttributes(File file,
                                                                   String hierarchicalFolderName,
                                                                   String duplicatesFolderNamePrefix)
                                                            throws IOException,
                                                                   DicomException,
                                                                   NoSuchAlgorithmException

Rename a DICOM file into a folder hierarchy based on its attributes.

Creates a folder structure in the current working directory of the form:

hierarchicalFolderName/PatientName [PatientID]/StudyDate StudyTime [StudyID - StudyDescription]/Series SeriesNumber [Modality - Series Description]/SOPInstanceUID.dcm

If the destination file already exists and is identical in content, the original is removed.

If the destination file already exists and is different in content, it is not overwritten, and the duplicate is moved into a separate duplicatesFolderNamePrefix_n folder.

Parameters:
file - the DICOM file
hierarchicalFolderName - where to store the renamed file
duplicatesFolderNamePrefix - where to store the renamed file if it is a non-identical duplicate of the existing file
Returns:
true if successful, false if not (e.g., if not a DICOM file)
Throws:
IOException
DicomException
NoSuchAlgorithmException

renameFileWithHierarchicalPathFromAttributes

public static boolean renameFileWithHierarchicalPathFromAttributes(File file)
                                                            throws IOException,
                                                                   DicomException,
                                                                   NoSuchAlgorithmException

Rename a DICOM file into a folder hierarchy based on its attributes.

Creates a folder structure in the current working directory of the form:

Sorted/PatientName [PatientID]/StudyDate StudyTime [StudyID - StudyDescription]/Series SeriesNumber [Modality - Series Description]/SOPInstanceUID.dcm

If the destination file already exists and is identical in content, the original is removed.

If the destination file already exists and is different in content, it is not overwritten, and the duplicate is moved into a separate Duplicates_n folder.

Parameters:
file - the DICOM file
Returns:
true if successful, false if not (e.g., if not a DICOM file)
Throws:
IOException
DicomException
NoSuchAlgorithmException

renameFileWithHierarchicalPathFromAttributes

public static boolean renameFileWithHierarchicalPathFromAttributes(String fileName)
                                                            throws IOException,
                                                                   DicomException,
                                                                   NoSuchAlgorithmException

Rename a DICOM file into a folder hierarchy based on its attributes.

Creates a folder structure in the current working directory of the form:

Sorted/PatientName [PatientID]/StudyDate StudyTime [StudyID - StudyDescription]/Series SeriesNumber [Modality - Series Description]/SOPInstanceUID.dcm

If the destination file already exists and is identical in content, the original is removed.

If the destination file already exists and is different in content, it is not overwritten, and the duplicate is moved into a separate Duplicates_n folder.

Parameters:
fileName - the DICOM file
Returns:
true if successful, false if not (e.g., if not a DICOM file)
Throws:
IOException
DicomException
NoSuchAlgorithmException

main

public static void main(String[] arg)

Recursively search the supplied paths for DICOM files and move them into a folder hierarchy based on their attributes.

Creates a folder structure in the current working directory of the form:

Sorted/PatientName [PatientID]/StudyDate StudyTime [StudyID - StudyDescription]/Series SeriesNumber [Modality - Series Description]/SOPInstanceUID.dcm

If the destination file already exists and is identical in content, the original is removed.

If the destination file already exists and is different in content, it is not overwritten, and the duplicate is moved into a separate Duplicates_n folder.

Parameters:
arg - array of one or more file or directory names