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.

Aside: I am using Nullsoft Scriptable Install System with Notepad++, and I can’t recommend this combination enough.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s