def destination(dcm)
      # Separate the path from the source file string:
      file_start = dcm.source.rindex(File.basename(dcm.source))
      if file_start == 0
        source_dir = "."
      else
        source_dir = dcm.source[0..(file_start-1)]
      end
      source_folders = source_dir.split(File::SEPARATOR)
      target_folders = @write_path.split(File::SEPARATOR)
      # If the first element is the current dir symbol, get rid of it:
      source_folders.delete('.')
      # Check for equalness of folder names in a range limited by the shortest array:
      common_length = [source_folders.length, target_folders.length].min
      uncommon_index = nil
      common_length.times do |i|
        if target_folders[i] != source_folders[i]
          uncommon_index = i
          break
        end
      end
      # Create the output path by joining the two paths together using the determined index:
      append_path = uncommon_index ? source_folders[uncommon_index..-1] : nil
      [target_folders, append_path].compact.join(File::SEPARATOR)
    end
def destination(dcm)
      # Separate the path from the source file string:
      file_start = dcm.source.rindex(File.basename(dcm.source))
      if file_start == 0
        source_dir = "."
      else
        source_dir = dcm.source[0..(file_start-1)]
      end
      source_folders = source_dir.split(File::SEPARATOR)
      target_folders = @write_path.split(File::SEPARATOR)
      # If the first element is the current dir symbol, get rid of it:
      source_folders.delete('.')
      # Check for equalness of folder names in a range limited by the shortest array:
      common_length = [source_folders.length, target_folders.length].min
      uncommon_index = nil
      common_length.times do |i|
        if target_folders[i] != source_folders[i]
          uncommon_index = i
          break
        end
      end
      # Create the output path by joining the two paths together using the determined index:
      append_path = uncommon_index ? source_folders[uncommon_index..-1] : nil
      [target_folders, append_path].compact.join(File::SEPARATOR)
    end
Creates a write path for the given DICOM object, based on the object's
 original file path and the write_path attribute.

 @param [DObject] dcm a DICOM object
 @return [String] the destination directory path