JSI Tip 0708. How do I strip spaces from an environment variable?

Jerold Schulman

September 8, 1998

1 Min Read
ITPro Today logo in a gray background | ITPro Today

In tip 537, we learned how to perform Environment Variable string substitiution.

To strip spaces from an environment variable, you can use the FOR command:

for /f %i in ("%Variable%") do set Variable=%i

If you want to include this in a batch job, them:

for /f %%i in ("%Variable%") do set Variable=%%i


Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like