Back to Blog
Arnošt Havelka

Revision 6: Automation & File Comparison

Create batch scripts and compare files to master advanced file operations.

Start Interactive Lesson
Revision 6: Automation & File Comparison

Revision 6: Automation & File Comparison

Welcome to advanced territory! In this final revision, you'll combine command redirection with batch scripting and learn how to compare files for differences. These skills unlock powerful automation capabilities.

Usage:echo
[command]
>
[file.bat]
>
Redirection operator — writes output to a file, overwriting if it exists.
echo
Displays text or commands.
.bat
Batch file extension — contains Windows commands to run sequentially.

Challenge 1: Create a Batch Script

Write a command to a batch file using echo and redirection. This creates an executable script that can run the same operations repeatedly without retyping.

Command Prompt
C:\Users\User>echo copy *.txt backup > backup.bat

By redirecting echo output to a .bat file, you've created a reusable script. Running backup.bat from the command line will execute the stored command automatically — perfect for repetitive tasks.

Challenge 2: Compare Files

Use the fc (file compare) command to identify differences between two files. This is crucial for verification and debugging.

Usage:fc
[file1]
[file2]
fc
File Compare — compares two files and shows differences.
/L
Performs ASCII comparison (text files).
/B
Performs binary comparison (image/executable files).
Command Prompt
C:\Users\User>fc config.ini config-backup.ini

The output shows differences between files. Each ***** marker indicates where files diverge. This is essential for version control, configuration audits, and detecting data corruption.


Knowledge Check

1 / 4

What does the > operator do in echo commands?

References

These Microsoft Learn and Windows documentation links provide authoritative details for the commands used in this article.

Up Next

Findstr Command

Advanced text search with regular expressions.