batch-files
Helps your agent write and fix simple scripts for Windows. It's useful for automating repetitive tasks on your computer.
What it does
This agent helps create and manage scripts called 'batch files' (.bat or .cmd) on Windows. It can write new scripts, fix errors in existing ones, and automate repetitive tasks on your computer.
When to use it
- ✓When you need to create a script to automate a task in Windows.
- ✓If a .bat or .cmd script is not working as expected.
- ✓To organize and maintain your command-line scripts.
Example of what to ask your AI
“Create a .bat script that copies all .txt files from one folder to another.”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
It understands how Windows commands are processed, from variable substitution to command execution. It also knows how to use control structures like 'if' and 'for' to make scripts make decisions and repeat actions.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add github/awesome-copilot --skill batch-filesOr download just the file:
curl -L https://raw.githubusercontent.com/github/awesome-copilot/main/skills/batch-files/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
Batch Files
A comprehensive skill for creating, editing, debugging, and maintaining Windows batch files (.bat/.cmd) using cmd.exe. Applies to CLI tool development, system administration automation, scheduled tasks, file operations scripting, and PATH-based executable scripts.
When to Use This Skill
- Creating or editing
.bator.cmdfiles - Automating Windows tasks (file operations, deployments, backups)
- Building CLI tools intended for a
bin/folder on PATH - Writing scheduled task scripts (SCHTASKS, Task Scheduler)
- Debugging batch script issues (variable expansion, error levels, quoting)
- Integrating batch scripts with external tools (curl, git, Node.js, Python)
- Scaffolding new batch-based projects with structured templates
Prerequisites
- Windows NT-based OS (Windows 7 or later)
- cmd.exe (built-in)
- Optional: a
bin/directory on PATH for distributing scripts as commands - Optional: PATHEXT configured to include
.BAT;.CMD(default on Windows)
Command Interpretation
cmd.exe processes each line through four stages in order:
- Variable substitution —
%VAR%tokens are replaced with environment variable values.%0–%9reference batch arguments.%*expands to all arguments. - Quoting and escaping — Caret
^escapes special characters (& | < > ^). Quotation marks prevent interpretation of enclosed special characters. In batch files,%%yields a literal%. - Syntax parsing — Lines are split into pipelines (
|), compound commands (&,&&,||), and parenthesized groups( ). - Redirection —
>overwrites,>>appends,<reads input,2>redirects stderr,2>&1merges stderr into stdout,>NULdiscards output.
Variables
Environment Variables
set _MY_VAR=Hello World
echo %_MY_VAR%
set _MY_VAR=
setwith no arguments lists all variablesset _PREFIXlists variables starting with_PREFIX- No spaces around
=—set name = valsets variable"name "to" val"
Special Variables
| Variable | Value |
|---|---|
%CD% |
Current directory |
%DATE% |
System date (locale-dependent) |
%TIME% |
System time HH:MM:SS.mm |
%RANDOM% |
Pseudorandom number 0–32767 |
%ERRORLEVEL% |
Exit code of last command |
%USERNAME% |
Current user name |
%USERPROFILE% |
Current user profile path |
%TEMP% / %TMP% |
Temporary file directory |
%PATHEXT% |
Executable extensions list |
%COMSPEC% |
Path to cmd.exe |
Scoping with SETLOCAL / ENDLOCAL
setlocal
set _LOCAL_VAR=scoped value
endlocal
REM _LOCAL_VAR is no longer defined here
To return a value from a scoped block:
endlocal & set _RESULT=%_LOCAL_VAR%
Delayed Expansion
Variables inside parenthesized blocks are expanded at parse time. Use delayed expansion for runtime evaluation:
setlocal EnableDelayedExpansion
set _COUNT=0
for /l %%i in (1,1,5) do (
set /a _COUNT+=1
echo !_COUNT!
)
endlocal
!VAR!expands at execution time (delayed)%VAR%expands at parse time (immediate)
Control Flow
Conditional Execution
if exist "output.txt" echo File found
if not defined _MY_VAR echo Variable not set
if "%_STATUS%"=="ready" (echo Go) else (echo Wait)
if %ERRORLEVEL% neq 0 echo Command failed
Comparison operators: equ, neq, lss, leq, gtr, geq. Use /i for case-insensitive string comparison.
Compound Commands
command1 & command2 & REM Always run both
command1 && command2 & REM Run command2 only if command1 succeeds
command1 || command2 & REM Run command2 only if command1 fails
FOR Loops
REM Iterate over a set of values
for %%i in (alpha beta gamma) do echo %%i
REM Numeric range: start, step, end
for /l %%i in (1,1,10) do echo %%i
REM Files in a directory
for %%f in (*.txt) do echo %%f
REM Recursive file search
for /r %%f in (*.log) do echo %%f
REM Directories only
for /d %%d in (*) do echo %%d
REM Parse command output
for /f "tokens=1,2 delims=:" %%a in ('ipconfig ^| findstr "IPv4"') do echo %%b
REM Parse file lines
for /f "usebackq tokens=*" %%a in ("data.txt") do echo %%a
GOTO and Labels
goto :main_logic
:usage
echo Usage: %~nx0 [options]
exit /b 1
:main_logic
echo Running main logic...
goto :eof
goto :eof exits the current batch or subroutine. Labels start with :.
Command-Line Arguments
| Syntax | Value |
|---|---|
%0 |
Script name as invoked |
…
FAQ
What are 'batch files'?
They are simple text files with the .bat or .cmd extension that contain a sequence of Windows commands to be executed automatically.
Do I need to install anything to use these scripts?
No, 'batch files' use the Windows command interpreter (cmd.exe) itself, which is already installed.
How does the script know which arguments to use?
You can pass information to the script when you run it, such as file or folder names, and the script can use them through special variables like %1, %2, etc.
Details
Original description by the author
Expert-level Windows batch file (.bat/.cmd) skill for writing, debugging, and maintaining CMD scripts. Use when asked to "create a batch file", "write a .bat script", "automate a Windows task", "CMD scripting", "batch automation", "scheduled task script", "Windows shell script", or when working with .bat/.cmd files in the workspace. Covers cmd.exe syntax, environment variables, control flow, strin
repo: github/awesome-copilot
Popularity
- GitHub stars
- 40k
- Ranking position
- #5033
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
acquire-codebase-knowledge
Helps your agent understand and document an existing code project. It's useful for onboarding new people or getting an overview of the architecture.
github/awesome-copilot
acreadiness-assess
Enables your agent to assess a project's readiness for AI and generate a report. It's useful for understanding how well a project is prepared to use AI tools.
github/awesome-copilot
acreadiness-generate-instructions
Helps your agent create instructions for AI tools based on an assessment. It's useful for improving how AI interacts with code and closing identified gaps.
github/awesome-copilot
acreadiness-policy
Enables your agent to help define or apply policies for AI project assessment. It's useful for standardizing how projects are evaluated and ensuring compliance.
github/awesome-copilot
Similar skills
benchmark-optimization-loop
Has your agent improve something's speed in a measured way. It tests multiple versions and chooses the fastest one that still works correctly.
affaan-m/ECC
change-impact
Helps your agent analyze the impact of code changes before making them. It compares the planned vs. actual results afterward, covering paths, data, tests, and documentation. Useful for risky or system-wide changes.
affaan-m/ECC
click-path-audit
Lets your agent trace all user buttons and interactions to find bugs. It finds issues where functions seem to work alone but fail together. Useful when bugs persist even after debugging.
affaan-m/ECC