duplicat
v0.1.1
Published
Duplicate files with ease
Readme
Commands
Duplicate (duplicat.duplicate): Opens a QuickPick menu showing matching templates and custom filename optionQuick Duplicate (duplicat.quickDuplicate): Automatically applies the first matching template without showing the menu
Both are available via the command palette or right click context menu
Config
| Name | Description | Default |
| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------- |
| duplicat.openDuplicatedFile | Immediately open the file after duplication (opens the last duplicated file when duplicating multiple files/folders at once) | true |
| duplicat.notifySuccess | Show a notification summarising all successful duplicated files/folders | true |
| duplicate.templates | Rules to provide quick options for common workflows | See below |
Templates
Templates in DupliCat allow you to define rules for automatic/suggestion-based file renaming. The default configuration for duplicate.templates is:
[{
"label": "Create test file",
"matches": "^(?!.*(test|spec)).*$",
"replacement": "${basename}.spec.${ext}",
"icon": "disassembly-editor-label-icon"
}]Each template has four key components:
label: The text displayed in the QuickPick menu when selecting a templatematches: A regular expression pattern that determines which files/folders the template applies toreplacement: The naming pattern used when duplicating matching files/foldersicon: Visual identifier shown in the QuickPick menu (optional, found here)
When you run the Duplicate (duplicat.duplicate) command, DupliCat tests each selected file/folder name against all defined templates. Any matching templates appear as options in the QuickPick menu.
Variables in Replacement Patterns
You can use these variables in your replacement patterns:
- ${basename}: The original file/folder name without extension
- ${ext}: The file extension (ignored for folders)
Examples
The default template matches any file that doesn't contain "test" or "spec" in its name and adds ".spec" before the extension:
example.js → example.spec.js
utils.ts → utils.spec.ts
Custom Filenames
You can type directly in the QuickPick menu to:
- Filter available templates by typing part of their label
- Create a completely custom filename by selecting the "Custom filename" option
Overwrites
Any potential overwrite will show a prompt to confirm/cancel the overwrite. In the case of duplicating multiple files/folders, only the 1 entry is cancelled and you can continue after answering the prompt.
Caveats
- Currently doesn't support using
{capture}in thereplacementfield of templates, but it will likely get added soon - Using the
Duplicatecommand with multiple files only works using the right click context menu. - Currently it's not possible to match against parent dirs, but I am open to exploring the idea.
License
MIT License © 2025 Ross Cooper
