Create Files Batch
Create Files Batch is a VSCode extension designed to streamline file creation by enabling the batch creation of files with a common name but varying suffixes or extensions. This extension is ideal for repetitive setups, such as creating multiple related files in the same folder or setting up new modules with similar structures (e.g., for a new use case in a backend).
Key Features
- Batch file creation with customizable file suffixes.
- Templates in settings.json allow pre-defining common file structures.
- On-the-fly configuration for custom file setups.
Installation
Simply install the extension from the Visual Studio Code Marketplace and start using it!
Getting Started
This guide shows how to set up and use Create Files Batch with both predefined templates and custom options.
Example: NestJS Use Case
Suppose you frequently add new "use case" files in a NestJS backend. Here’s how to automate this structure with a template:
Add a Template to settings.json
file in .vscode
folder
Open your settings.json and define a template with a label, description, and file suffixes:
{
"create-files-batch": {
"templates": [
{
"label": "NestJS use case",
"description": "Creates all the needed files for a new use case in the application.",
"suffixes": [".controller.ts", ".service.ts", ".repository.ts", ".module.ts"]
}
]
}
}
Create Files Using the Template
- Open the Command Palette (
Ctrl+Shift+P
or Cmd+Shift+P
) and search for Create: Multiple Files...
.
- If more than one workspace is open, select the workspace to create files in.
- Select the "NestJS use case" template from the list.
- Specify the destination path.
- Enter a common file name prefix. For example, entering "auth" will create:
auth.controller.ts
auth.service.ts
auth.repository.ts
auth.module.ts
Creating Files Without a Predefined Template
- Open the Command Palette and select
Create: Multiple Files...
.
- If prompted, choose the workspace.
- Select the built-in "Custom" option.
- Manually specify the suffixes you’d like to use.
- Follow the remaining prompts to choose a destination and enter the prefix.
Screenshots
Create: Multiple Files...
command:
Workspace selection
Template selection
Destination folder specification
File name specification
Additional Configuration Options
You can define multiple templates in your settings.json for different use cases, each with a unique label, description, and suffix structure.
{
"create-files-batch": {
"templates": [
{
"label": "New NestJS use case",
"description": "Creates all the needed files for a new use case in the application.",
"suffixes": [".controller.ts", ".service.ts", ".repository.ts", ".module.ts"]
},
{
"label": "New NestJS use case with test files",
"description": "Creates all the needed files for a new use case in the application including test files.",
"suffixes": [".controller.ts", ".controller.spec.ts", ".service.ts", ".service.spec.ts", ".repository.ts", ".repository.spec.ts", ".module.ts"]
}
]
}
}
Attributions