Skip to content
CppCooperProgramming Portfolio

Article

Recursive Collection and Full-Path Matching in RegexRenamer

Data Processing

Two files can share a name while belonging to very different parts of a directory tree. For example, C:\audio\menu\theme.wav and C:\audio\battle\theme.wav both have the basename theme.wav. A pattern that can see the path has information that a basename-only match does not.

This 2019 RegexRenamer modification adds recursive file collection and a full-path option to an existing Windows Forms renaming utility. The original application, regex functionality, and third-party controls remain their authors’ work. The change is in which files are collected and which text is supplied to matching and preview code.

Choose one representation consistently

Helpers select either Name or FullName for filesystem objects, with corresponding handling for the application’s own file records. Filtering and previews use those helpers. A default-enabled Full Path option supplies the directory context as well as the filename.

The option changes the input to a regular expression, so it also changes what a pattern can match. That choice has to remain consistent across the visible file list, filtering, and preview; otherwise the user could be shown a different name from the one being matched.

The remaining edges of the extension

The recursive collector gathers files from each child directory and appends them to the result. Although it receives a depth argument and decrements it on recursion, it never checks that argument. The parameter therefore does not impose a traversal-depth limit.

Full-path validation has another incomplete edge. It skips the first path token during the invalid-character scan. When subdirectory renaming is disabled, the entire input is one token, so that scan is skipped altogether; later validation checks still run. The historical extension needs these cases checked before treating its path handling as complete.

A separate commit disables assembly and manifest signing. Project XML parses, but a native .NET Framework/Windows Forms build and GUI check remain outstanding. This article describes the narrow fork modification and its limits, without claiming fully validated renaming behavior.