Skip to content

Commit d0d8a5a

Browse files
committed
Update power rename doc
1 parent e056454 commit d0d8a5a

File tree

1 file changed

+93
-16
lines changed

1 file changed

+93
-16
lines changed

doc/devdocs/modules/powerrename.md

Lines changed: 93 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,100 @@
1-
#### [`dllmain.cpp`](/src/modules/powerrename/dll/dllmain.cpp)
2-
TODO
1+
# PowerRename
32

4-
#### [`PowerRenameExt.cpp`](/src/modules/powerrename/dll/PowerRenameExt.cpp)
5-
TODO
3+
PowerRename is a Windows shell extension that enables batch renaming of files using search and replace or regular expressions.
64

7-
#### [`Helpers.cpp`](/src/modules/powerrename/lib/Helpers.cpp)
8-
TODO
5+
## Overview
96

10-
#### [`PowerRenameItem.cpp`](/src/modules/powerrename/lib/PowerRenameItem.cpp)
11-
TODO
7+
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:
8+
- Preview changes before applying them
9+
- Use search and replace with regular expressions
10+
- Filter items by type (files or folders)
11+
- Apply case-sensitive or case-insensitive matching
12+
- Save and reuse recent search/replace patterns
1213

13-
#### [`PowerRenameManager.cpp`](/src/modules/powerrename/lib/PowerRenameManager.cpp)
14-
TODO
14+
## Architecture
1515

16-
#### [`PowerRenameRegEx.cpp`](/src/modules/powerrename/lib/PowerRenameRegEx.cpp)
17-
TODO
16+
PowerRename consists of multiple components:
17+
- Shell Extension DLL (context menu integration)
18+
- WinUI 3 UI application
19+
- Core renaming library
1820

19-
#### [`Settings.cpp`](/src/modules/powerrename/lib/Settings.cpp)
20-
TODO
21+
### Technology Stack
22+
- C++/WinRT
23+
- WinUI 3
24+
- COM for shell integration
2125

22-
#### [`trace.cpp`](/src/modules/powerrename/lib/trace.cpp)
23-
TODO
26+
## Context Menu Integration
27+
28+
PowerRename integrates with the Windows context menu following the [PowerToys Context Menu Handlers](../common/context-menus.md) pattern. It uses a dual registration approach to ensure compatibility with both Windows 10 and Windows 11.
29+
30+
### Registration Process
31+
32+
The context menu registration entry point is in `PowerRenameExt/dllmain.cpp::enable`, which registers:
33+
- A traditional shell extension for Windows 10
34+
- A sparse MSIX package for Windows 11 context menus
35+
36+
For more details on the implementation approach, see the [Dual Registration section](../common/context-menus.md#1-dual-registration-eg-imageresizer-powerrename) in the context menu documentation.
37+
38+
## Code Components
39+
40+
### [`dllmain.cpp`](/src/modules/powerrename/dll/dllmain.cpp)
41+
Contains 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.
42+
43+
### [`PowerRenameExt.cpp`](/src/modules/powerrename/dll/PowerRenameExt.cpp)
44+
Implements the shell extension COM interfaces required for context menu integration, including:
45+
- `IShellExtInit` for initialization
46+
- `IContextMenu` for traditional context menu support
47+
- `IExplorerCommand` for Windows 11 context menu support
48+
49+
### [`Helpers.cpp`](/src/modules/powerrename/lib/Helpers.cpp)
50+
Utility functions used throughout the PowerRename module, including file system operations and string manipulation.
51+
52+
### [`PowerRenameItem.cpp`](/src/modules/powerrename/lib/PowerRenameItem.cpp)
53+
Represents a single item (file or folder) to be renamed. Tracks original and new names and maintains state.
54+
55+
### [`PowerRenameManager.cpp`](/src/modules/powerrename/lib/PowerRenameManager.cpp)
56+
Manages the collection of items to be renamed and coordinates the rename operation.
57+
58+
### [`PowerRenameRegEx.cpp`](/src/modules/powerrename/lib/PowerRenameRegEx.cpp)
59+
Implements the regular expression search and replace functionality used for renaming.
60+
61+
### [`Settings.cpp`](/src/modules/powerrename/lib/Settings.cpp)
62+
Manages user preferences and settings for the PowerRename module.
63+
64+
### [`trace.cpp`](/src/modules/powerrename/lib/trace.cpp)
65+
Implements telemetry and logging functionality.
66+
67+
## UI Implementation
68+
69+
PowerRename uses WinUI 3 for its user interface. The UI allows users to:
70+
- Enter search and replace patterns
71+
- Preview rename results in real-time
72+
- Access previous search/replace patterns via MRU (Most Recently Used) lists
73+
- Configure various options
74+
75+
### Key UI Components
76+
77+
- Search/Replace input fields with x:Bind to `SearchMRU`/`ReplaceMRU` collections
78+
- Preview list showing original and new filenames
79+
- Settings panel for configuring rename options
80+
- Event handling for `SearchReplaceChanged` to update the preview in real-time
81+
82+
## Debugging
83+
84+
### Debugging the Context Menu
85+
86+
See the [Debugging Context Menu Handlers](../common/context-menus.md#debugging-context-menu-handlers) section for general guidance on debugging PowerToys context menu extensions.
87+
88+
### Debugging the UI
89+
90+
To debug the PowerRename UI:
91+
92+
1. Add file paths manually in `\src\modules\powerrename\PowerRenameUILib\PowerRenameXAML\App.xaml.cpp`
93+
2. Set the PowerRenameUI project as the startup project
94+
3. Run in debug mode to test with the manually specified files
95+
96+
### Common Issues
97+
98+
- Context menu not appearing: Ensure the extension is properly registered and Explorer has been restarted
99+
- UI not launching: Check Event Viewer for errors related to WinUI 3 application activation
100+
- Rename operations failing: Verify file permissions and check for locked files

0 commit comments

Comments
 (0)