Weblog (or Blog)
Sunday, February 09, 2014
Batch files are command-line scripts for Windows. They can be used to automate tasks on your computer. Batch files or scripts can be used for backup, moving to a project-related directory, cleaning up your hard drive, and almost any other task you can do from within Windows.
The Windows batch scripting "language" is not as fully capable as *nix shell scripting. Microsoft has provided a new tool, PowerShell, to improve Windows scripting capability. PowerShell gets good reviews, but it is a completely new language that I haven't gotten into yet, so you will not see much about it here.
Batch files, with the file extension .bat, have been around since DOS. The commands available for scripting have increased significantly since Windows NT and scripts that take advantage of those additional commands may have a file extension of either .bat or .cmd, the latter indicating that NT and later commands have been used and the script likely will not run under DOS or Windows 9x. I'll be writing more about specific batch scripts that I use, but here is an article on batch file basics that is more complete than I would ever provide. I have not read the book from which the article is taken, but it gets good reviews and the same author has written an update entitled Windows 7 and Vista Guide to Scripting, Automation, and Command Line Tools that covers Windows 7 and PowerShell. But the linked article will get you started on the basics of batch files.