I was recently working on batch files to facilitate building our automated build process. One step of the process involves naming the release, which creates a folder with the provided name for the release. One issue I found with my code was that I was doing the following:
COPY setup.exe "%PackageName%\setup.exe" /V /Y IF EXIST setup.exe DEL setup.exe /F /Q
That’s right, I was copying and then deleting. This sounds eerily familiar to the below code.
MOVE /Y setup.exe "%PackageName%\setup.exe"
Not only has a line of code been eliminated, but a branch has been removed. The less code that can be used to support the same feature or set of features the better. This may be less apparent in a < 20 line batch file, but the same habits will be used in more complex programs.