Back to library
AI
best practice

Perform Bulk File Refactoring with the /batch Command

Execute code edits across multiple files simultaneously using /batch.

Use the `/batch` command to perform large-scale refactoring or multi-file updates in a single action instead of processing files one by one.

Qwen

The Scenario

You are refactoring a project and need to change a specific function signature or rename a variable across dozens of files. Doing this one-by-one is prone to error and time-consuming.

Before & after

The old way

You would have to open each file individually, paste the code, ask for the edit, and save. For a 20-file project, this takes at least 30-40 minutes of tedious manual effort.

With AI

Use the `/batch` command in Qwen Code to apply the transformation to all files simultaneously. This reduces the task to roughly 2-4 minutes including verification.

The Prompt

/batch [SPECIFIC_REFACTORING_RULE] across all files in [DIRECTORY_PATH]

Version 0.15.0 introduced batch multi-file operations. This allows the agent to process multiple files in one go, which is essential for refactoring, updating dependencies, or changing common patterns across a codebase.

Source

Blog | Qwen Code Docs
"v0.15.0 is out: cross-session memory... /batch command, Hook expansion, and subagent background execution."