Home > Back-end >  Windows command SET seems possibly redundant?
Windows command SET seems possibly redundant?

Time:04-01

I've inherited a batch file which reads major, minor and build numbers from a text file as part of a long-established build process - the actual reading part code is a simple FOR /F:

FOR /F "tokens=1,2,3* delims=." %%A IN (C:\MyBuildArea\version.txt) DO (
  SET Major=%%A
  SET Minor=%%B
  SET Build=%%C
)

However this is followed by the line:

SET Build=%Build: =%

I don't understand this last line - what it is doing. Guessing it might be trying to catch and remove a trailing space (?) from the original file read as the FOR /F was delimited on dot (".") not space.

Hoping someone can help me understand - is this line redundant or serving some purpose?

CodePudding user response:

The command SET Build=%Build: =% will simply substitute all spaces with nothing, i.e. it will remove all spaces in the text stored in Build.

See set /? on command prompt for details.

  • Related