User Defined Commands - Batch Script (.BAT)
Batch Script Commands leverage the power of Windows batch scripting to create sophisticated automation workflows that combine Multi Commander's dynamic context information with traditional DOS/Windows command-line operations. This command type generates and executes .BAT files on-demand, enabling complex multi-step operations, external tool integration, and system-level automation that bridges file management with comprehensive system administration tasks.
Windows Batch Integration
Transform Multi Commander into a powerful scripting environment by generating dynamic batch files that combine traditional Windows batch commands with real-time file context information. Batch Script Commands provide unlimited flexibility for system automation, external tool orchestration, and complex file processing workflows while maintaining the familiar and reliable Windows batch scripting environment.
Batch Script Commands Overview
Batch Script Commands provide access to the full power of Windows batch scripting while integrating seamlessly with Multi Commander's file management context, creating dynamic automation solutions that span from simple file operations to complex system administration tasks.
Batch Scripting Heritage
Windows Batch Foundation
- DOS Legacy: Built on the time-tested Windows batch system dating back to DOS
- Universal Compatibility: Works on all Windows versions with standard command interpreter
- Familiar Syntax: Uses well-known batch scripting commands and structures
- System Integration: Direct access to Windows command-line tools and utilities
- File Processing: Excellent for batch file operations and transformations
- Tool Chaining: Connect multiple command-line tools in sequence
- Output Redirection: Pipe output between commands for complex workflows
- Error Handling: Built-in error codes and conditional execution
Multi Commander Enhancement
- Dynamic Context: MultiTags inject current file paths, selections, and panel information
- On-Demand Generation: Scripts created in real-time with current context values
- Working Directory: Automatic working folder set to current source panel path
- Parameter Support: Command-line arguments passed through MultiTags
Power and Simplicity
Batch Script Commands combine the unlimited flexibility of Windows batch scripting with Multi Commander's dynamic file context, creating powerful automation without requiring advanced programming knowledge.
Key Advantages
Flexibility and Power
- Unlimited Operations: Any operation possible in Windows batch scripting
- Tool Integration: Seamlessly integrate any command-line tool or utility
- Complex Workflows: Multi-step operations with conditional logic
- File Processing: Sophisticated batch file manipulation and transformation
System Integration
- Native Windows: Uses standard Windows command interpreter
- No Dependencies: Requires no additional software or frameworks
- Administrative Tasks: Full access to system administration commands
- Legacy Support: Works with older Windows systems and tools
Primary Applications
System Administration
- File Operations: Complex copy, move, and synchronization tasks
- Backup Scripts: Automated backup with compression and versioning
- Log Processing: Parse and analyze log files with text processing tools
- System Maintenance: Cleanup, optimization, and monitoring tasks
Development Workflows
- Build Automation: Compile and deploy applications
- Code Processing: Format, analyze, and transform source code
- Version Control: Git operations and repository management
- Testing Automation: Run test suites and generate reports
How Batch Script Commands Work
Understanding the execution process of Batch Script Commands helps you create effective automation solutions that leverage both Windows batch capabilities and Multi Commander's dynamic context information.
Execution Process

Batch Script Command configuration interface showing script content with MultiTags
Step-by-Step Execution
- Command Triggered: User executes the batch script command
- Context Capture: Multi Commander captures current panel states and file selections
- MultiTag Processing: Dynamic tags replaced with actual values
- Script Generation: Complete .BAT file created with processed content
- Working Directory Set: Batch file working folder set to source panel path
- Script Execution: Windows command interpreter runs the generated script
- Output Display: Command results displayed in appropriate interface
- Cleanup: Temporary files cleaned up after execution
Working Directory Behavior
- Automatic Setting: Working folder automatically set to current source panel path
- Relative Paths: File operations use source panel as base directory
- Context Awareness: Commands operate within current file management context
- Path Consistency: Ensures script operations align with user's current location
Dynamic Generation
Each execution creates a fresh batch file with current context values, ensuring scripts always operate with up-to-date information from Multi Commander's current state.
Command Parameters and Options
Batch Script Commands support flexible parameter passing and execution options to create adaptable automation solutions that can be customized at runtime through command-line arguments.
Parameter System
Parameter Access Methods
Command Line Bar
- Direct Execution: Type command name followed by parameters
- Space Separated: Parameters separated by spaces
- Quoted Arguments: Use quotes for parameters containing spaces
- Immediate Access: Parameters available as
${param:0}
,${param:1}
, etc.
Button Integration
- Dropped Files: Enable "Use Dropped files as parameter" option
- File Paths: Dropped file paths become command parameters
- Drag and Drop: Drag files onto button to pass as parameters
- Multiple Files: Multiple dropped files create multiple parameters
Script Integration
- Custom Commands: Called from Custom Commands with parameters
- MultiScript: Invoked from MultiScript with dynamic parameters
- Automation: Parameters passed from other automation systems
- Workflow Chaining: Output from one command becomes input to another
Parameter Examples
${param:0}
- First parameter${param:1}
- Second parameter${param:2}
- Third parameter- And so on for additional parameters
Parameter Usage in Batch Scripts
Flexible Archive Creation
@echo off
set ARCHIVE_NAME=${param:0}
if "%ARCHIVE_NAME%"=="" set ARCHIVE_NAME=backup
7z a "${targetpath}\%ARCHIVE_NAME%.zip" "${selectedfilepaths}"
echo Created %ARCHIVE_NAME%.zip in target directory
Usage: "mycommand ProjectBackup" creates ProjectBackup.zip
Parameterized File Processing
@echo off
set OPERATION=${param:0}
set TARGET_EXT=${param:1}
for %%f in (${selectedfiles}) do (
%OPERATION% "%%f" "%%~nf.%TARGET_EXT%"
)
Usage: "convert jpg png" converts selected files from JPG to PNG
Execution Options
Current Limitation: Batch Script Commands currently do not support additional execution options like "Display Confirmation" or "Run Separately" that are available in other command types. Parameter passing provides the primary customization mechanism.
Practical Batch Script Examples
These comprehensive examples demonstrate real-world applications of Batch Script Commands across different automation scenarios, from simple file operations to complex system administration tasks.
File Operations
Smart Backup Script
@echo off
set BACKUP_DIR=${param:0}
if "%BACKUP_DIR%"=="" set BACKUP_DIR=Backup
mkdir "${targetpath}\%BACKUP_DIR%" 2>nul
xcopy "${sourcepath}\*" "${targetpath}\%BACKUP_DIR%\" /s /e /h /y
echo Backup completed to %BACKUP_DIR%
Usage: Creates organized backups with optional custom directory name
File Synchronization
@echo off
robocopy "${sourcepath}" "${targetpath}" /mir /xd .git /xf *.tmp
if %ERRORLEVEL% leq 1 (
echo Synchronization completed successfully
) else (
echo Synchronization completed with warnings
)
Usage: Mirror source to target, excluding git and temporary files
File Organization
@echo off
for %%f in (${selectedfiles}) do (
for /f "tokens=1 delims=." %%e in ("%%~xf") do (
mkdir "${targetpath}\%%e" 2>nul
move "%%f" "${targetpath}\%%e\"
)
)
echo Files organized by extension
Usage: Organize selected files into folders by file extension
Development Tools
Git Operations
@echo off
cd /d "${sourcepath}"
git add .
git commit -m "${param:0}"
git push origin main
echo Changes committed and pushed: ${param:0}
Usage: "gitcommit Added new feature" commits with custom message
Build Automation
@echo off
cd /d "${sourcepath}"
echo Building project...
dotnet build --configuration Release
if %ERRORLEVEL%==0 (
echo Build successful
dotnet publish -o "${targetpath}\publish"
) else (
echo Build failed
)
Usage: Build .NET project and publish to target directory
Code Analysis
@echo off
set REPORT_FILE=${targetpath}\analysis_report.txt
echo Code Analysis Report > "%REPORT_FILE%"
echo ==================== >> "%REPORT_FILE%"
dir "${sourcepath}\*.cs" /s /b | find /c ":" >> "%REPORT_FILE%"
echo Total C# files found >> "%REPORT_FILE%"
notepad "%REPORT_FILE%"
Usage: Generate and display code analysis report
System Administration
Log Analysis
@echo off
set LOG_FILE=${focusfilepath}
set REPORT=${targetpath}\log_analysis.txt
echo Analyzing %LOG_FILE% > "%REPORT%"
find /c "ERROR" "%LOG_FILE%" >> "%REPORT%"
find /c "WARNING" "%LOG_FILE%" >> "%REPORT%"
echo Analysis complete - check %REPORT%
Usage: Analyze log file and create summary report
System Cleanup
@echo off
echo Cleaning temporary files in ${sourcepath}
del /q /s "${sourcepath}\*.tmp" 2>nul
del /q /s "${sourcepath}\*.log" 2>nul
for /d %%d in ("${sourcepath}\temp*") do rd /s /q "%%d" 2>nul
echo Cleanup completed
Usage: Clean temporary files and directories
Security Audit
@echo off
set AUDIT_FILE=${targetpath}\security_audit.txt
echo Security Audit - %DATE% %TIME% > "%AUDIT_FILE%"
icacls "${sourcepath}" /T >> "%AUDIT_FILE%"
echo Audit saved to %AUDIT_FILE%
start notepad "%AUDIT_FILE%"
Usage: Generate security permissions audit report
Media Processing
Image Batch Conversion
@echo off
set FORMAT=${param:0}
if "%FORMAT%"=="" set FORMAT=jpg
for %%f in (${selectedfiles}) do (
echo Converting %%f to %FORMAT%
magick "%%f" "%%~nf.%FORMAT%"
)
echo Conversion to %FORMAT% completed
Usage: "convert png" converts selected images to PNG format
Video Processing
@echo off
set OUTPUT_DIR=${targetpath}\processed
mkdir "%OUTPUT_DIR%" 2>nul
for %%f in (${selectedfiles}) do (
echo Processing %%f
ffmpeg -i "%%f" -vcodec libx264 "%OUTPUT_DIR%\%%~nf_processed.mp4"
)
echo Video processing completed
Usage: Process selected videos with FFmpeg encoding
Audio Extraction
@echo off
for %%f in (${selectedfiles}) do (
echo Extracting audio from %%f
ffmpeg -i "%%f" -vn -acodec mp3 "${targetpath}\%%~nf.mp3"
)
echo Audio extraction completed
Usage: Extract audio tracks from selected video files
Batch Script Commands Mastery
Master Batch Script Commands by leveraging the familiar Windows batch scripting environment enhanced with Multi Commander's dynamic context through MultiTags. Remember to always quote path-based MultiTags to handle spaces and special characters, use parameter passing for flexible script customization, and implement proper error handling with existence checks and error level validation. Start with simple file operations before progressing to complex multi-tool workflows, and take advantage of the automatic working directory setting to simplify relative path operations. These commands provide unlimited automation potential while maintaining compatibility with existing Windows tools and administrative procedures.
Related Documentation
Enhance your Batch Script Commands knowledge with: User Defined Commands Overview, MultiTags Reference, External Commands, MultiScript, and other command types: Internal Commands, Custom Commands.