doc/devdocs/modules/powerrename.md
Public overview - Microsoft Learn
PowerRename is a Windows shell extension that enables batch renaming of files using search and replace or regular expressions.
PowerRename provides a powerful and flexible way to rename files in File Explorer. It is accessible through the Windows context menu and allows users to:
PowerRename consists of multiple components:
PowerRename integrates with the Windows context menu following the PowerToys Context Menu Handlers pattern. It uses a dual registration approach to ensure compatibility with both Windows 10 and Windows 11.
The context menu registration entry point is in PowerRenameExt/dllmain.cpp::enable, which registers:
For more details on the implementation approach, see the Dual Registration section in the context menu documentation.
dllmain.cppContains the DLL entry point and module activation/deactivation code. The key function RunPowerRename is called when the context menu option is invoked, which launches the PowerRenameUI.
PowerRenameExt.cppImplements the shell extension COM interfaces required for context menu integration, including:
IShellExtInit for initializationIContextMenu for traditional context menu supportIExplorerCommand for Windows 11 context menu supportHelpers.cppUtility functions used throughout the PowerRename module, including file system operations and string manipulation.
PowerRenameItem.cppRepresents a single item (file or folder) to be renamed. Tracks original and new names and maintains state.
PowerRenameManager.cppManages the collection of items to be renamed and coordinates the rename operation.
PowerRenameRegEx.cppImplements the regular expression search and replace functionality used for renaming.
Settings.cppManages user preferences and settings for the PowerRename module.
trace.cppImplements telemetry and logging functionality.
PowerRename uses WinUI 3 for its user interface. The UI allows users to:
SearchMRU/ReplaceMRU collectionsSearchReplaceChanged to update the preview in real-timeSee the Debugging Context Menu Handlers section for general guidance on debugging PowerToys context menu extensions.
To debug the PowerRename UI:
\src\modules\powerrename\PowerRenameUILib\PowerRenameXAML\App.xaml.cpp