Unique File Naming and Flat Folder Structures

Starting with Document Conversion Service 3.0.019, the Watch Folder Service now includes the ability to create each output file with a unique name, as well as being able to flatten any folder structure used or dropped into the InputFolder.

What is Flattening Folder Structures?

When you flatten a folder structure, the idea is to remove all subfolders (and subfolders of folders, etc.) of a particular folder, and place all of the files into a single folder.

The default Watch Folder behavior is to maintain any folder structure found in the InputFolder when looking for files to convert, which recreates the folder structure in the OutputFolder. This can be disabled to allow the creation of all output files in the OutputFolder location, essentially flattening the folder.

The setting OutputFolder.MaintainInputFolderStructure controls this behavior. It defaults to true, meaning it keeps the folder structure. Set this to false to create all output files in a single folder.

Caution

If you are flattening folders you may encounter files with the same names coming from different subfolders. Use the Unique File Names settings below to create each filename with a unique name in the OutputFolder.

 

Unique File Names

Each Watch Folder can be configured to create a unique filename for every file that if finds. This is especially useful if you are flattening folders as explained above.

The unique file names are created using Globally Unique IDs, or GUIDs. A GUID is a sequences of alphanumeric characters, such as 4c4636f7-e9c5-4c4c-97af-081a328ba7c5, that is for all practical purposes, unique. These unique strings can be placed before, after or both before and after the base filename to create unique output file names.

Use OutputFolder.PrependUniqueGUIDToFilename and OutputFolder.AppendUniqueGUIDToFilename set to true to control if a GUID is added and where it is placed. The setting OutputFolder.RemoveHyphensFromGUID allows the hyphens to be removed from the GUID, leaving the GUID as a string of alphanumeric characters (4c4636f7e9c54c4c97af081a328ba7c5).

An default separator string of an underscore character (_) is used between the GUD and the original filename. It is defined using the OutputFolder.UniqueGUIDSeparatorCharacter setting. This can be changed to a different character, a sequence of characters or left as an empty string to not use the separator character between the GUID and the filename. If any invalid file naming characters such as <, >, or others, are found in this string, it will default back to a single underscore.

When creating serialized output, where each output file is a single page from the input document, each file in the sequence will have the same GUID. Set OutputFolder.UseSameGUIDForEachSerializedFile to false to use a unique GUID for each file in the sequence.

Code Sample - Sample Flattening and Unique Naming Settings

 

<WatchFolders>
 
  <WatchFolder Name="ConvertToTIFF Watch Folder">
    <Settings>

      ...

 

      <!-- Flatten folder structure and add a GUID to the beginning of the filename. -->

      <!-- 4c4636f7-e9c5-4c4c-97af-081a328ba7c5_ Filename.tif. -->

 
      <add Name="OutputFolder.MaintainInputFolderStructure" Value="false" />

    

      <add Name="OutputFolder.PrependUniqueGUIDToFilename" Value="true" />

      <add Name="OutputFolder.AppendUniqueGUIDToFilename" Value="false" />

      <add Name="OutputFolder.UseSameGUIDForEachSerializedFile" Value="true" />

 

      <add Name="OutputFolder.RemoveHyphensFromGUID" Value="false" />

      <add Name="OutputFolder.UniqueGUIDSeparatorCharacter" Value="_" />

      ...
        
    </Settings>
  </WatchFolder>
</WatchFolders>