Tuesday, 27 August 2013

check if current dir contains spaces in its name

check if current dir contains spaces in its name

I would like my script to abort if the current directory contains a space
in its name.
My thought was to use %~s but so far my efforts are frustrating. The
following works, but I don't like it. My attempts at passing a parameter
have been futile.
Any suggestion for improvements?
@echo off
setlocal enableextensions
for /f %%f in ("%cd%") do (
if NOT "%%f" == "%cd%" (
echo bad dir"%cd%" contains spaces
) else (
echo no spaces in "%cd%"
)
)
)

No comments:

Post a Comment