DocKIT: Rename folders/files based on patterns using renaming rules

In continuation with the previous blog post that deals with the folder and file rename options, here we discuss how to deal with renaming of folders/files that contain illegal characters.

As said earlier, folders and files residing in legacy systems will have having special characters that are invalid (disallowed) in SharePoint. DocKIT facilitates this renaming by providing folder and file naming rules while migrating into SharePoint.

Certain users might also need migration of different versions of a file with their version named with certain patterns. DocKIT also supports this file version history creation seamlessly.

Rename folders & files using naming rules

This option is intended /recommended for renaming folders & files that have characters not accepted in SharePoint as part of their names.

SharePoint disallows certain invalid characters in the folder and file names. In order to overcome this behavior, you need to replace certain characters that appear in Windows folder & file names and are invalid folder / file characters in SharePoint libraries, with valid characters (all characters except ~ # % & { } * | : < > / ?) in SharePoint.

For this, you can use the “Folder & File Renaming Rules” feature in DocKIT. This feature in DocKIT uses ‘Regular Expressions’ technique that is widely used in software applications where character pattern matching is crucial.

Consider the following cases:

Example 1: Order of entries when constructing renaming rules

The Folder and File Renaming rule in DocKIT requires the rule entries to be correctly placed for successful and meaningful replacement of invalid characters. The order of the entries (sequence) is important depending on the name of the files and folders. For example, if you want dot and double underscore OR triple dots to be treated as a single entity, then a rule entry with this value has to be given first. After this, you should provide dot and single underscore OR double dots value as entry.

Example:

Invalid File NameValid File NameDescription of the Renaming requirement
Sa…ple File 1.docSample File 1,docReplace 3 dots with ‘m’
Sam..le File2.docSample File2.docReplace 2 dots with ‘p’
_ample File3.docSample File3.docReplace_ with ‘S’
.Feb Report.xlsxFeb Reprt.xlsxRemove dot if the file name starts with . (dot)
Jan Report.xlsJan Report.xlsRemove dot if the file name ends with . (dot)Replace two consecutive dots with one
._March Report.pdfMarch Report.pdfReplace ._ with empty
.__ April Report.txtApril Report.txtReplace .__ ( dot, two underscores) with empty
__ May Report.pptxMay Report.pptxReplace __ (two consecutive underscores) with empty
._. June Report.pptjustify;line-height:normal;mso-yfti-cnfc:128″>June Report.pptReplace ._. (dot, underscore,
dot) with empty

Equivalent Naming Rules:

FindReplaceDescription
mReplace 3 dots with ‘m’
..pReplace 2 dots with ‘p’
.*Remove dot if the file name starts with . (dot)
*.Remove dot if the file name ends
with . (dot)
.__Replace .__ ( dot, two underscores) with empty
._.Replace ._. (dot, underscore, dot) with empty
._Replace ._ with empty
__Replace __ (two consecutive underscores) with empty
_SReplace _ with ‘S’

Figure 1: Naming rule as specified in DocKIT application

Example 2: Usage of reserved characters

The ‘Regular Expressions’ technique used by DocKIT for pattern matching categorizes some of the operators as reserved and has its own meaning for the operators in the pattern syntax. In order to treat the reserved characters as normal characters like ‘A’, ‘1’, you have to use ” (backslash) as an escape sequence character in DocKIT Renaming rule as given below:

Invalid file nameValid file nameDescriptionNaming rule
FindReplace
My File name#.xlsMy File name.xlsReplace # with empty#
Programs & Schedules.docxPrograms and Schedules.docxReplace & with ‘and’&and
My $ File name.docxMy File name.docxReplace $ with empty$
policydoc *74565.xlspolicydoc 74565.xlsReplace * with empty*
Sample.DocSampleDocReplace . with empty.
Sample?FileSampleTextFileReplace ? with ‘Text’?Text
Test^DocumentTestdocumentReplace ^ with empty^
Sample+FileSampleTextFileReplace plus with ‘Text’+Text
Word<DocumentWordDocumentReplace < with empty<
PDF>DocumentPDFDocumentReplace > with empty>
[DocumentDocumentReplace [ with empty[
Sample]SampleFileReplace ] with ‘File’]File
(FileDocumentFileReplace ( with ‘Document’(Document
TextFile)TextFileReplace ) with empty)

Create file version history by using certain naming patterns

We will discuss a situation where certain files in a folder have their names appended with version numbers. If you would like these version numbers to stack up nicely as version history of the file / document, this is what you can do.

Example 1: Uniform file naming pattern for file version

Invalid File NameValid File NameDescription

Naming Rule

FindReplace
My File name_v1.0.docxMy File name.docxReplace underscore, v and version number appended with the parent file name with empty so as to create as respective versions of a file
First version
*_v??.??
My File name_v1.1.docxMy File name.docxNext minor version
My File name_v1.2.docxMy File name.docxNext minor version

Example 2: Random file naming pattern for file version:

Invalid File NameValid File NameDescription

Naming Rule

FindReplace
My doc_v1.0.docMy doc.docReplace underscore, v and version number appended with the parent file name with empty so as to create as respective versions of a file
First version
*_v*
*v??.??
v
My docv1.1.docMy doc.docNext minor version
My docv1.2.docMy doc.docNext minor version

Note: Entries under the Find section should be in the same order as listed.

Figure 2: File Settings in DocKIT Task Wizard

To create version history, select ‘Create new version’ option in ‘File Settings’ step in DocKIT Task Wizard.

For more information, please refer the following help sections in the Dockit online help document. You can launch the help document from Help menu (Help -> Contents menu) in the application.

  • DocKIT Features -> Folder & File Renaming Rules
  • DocKIT Special Cases -> Rename Documents in File System