Edit FOR Variable in CMD.exe

  • Thread starter Thread starter NvrBst
  • Start date Start date
N

NvrBst

FOR %B IN (*.*) echo "%B"

Is there any way to edit the %B variable? I know the basic ones like
"%~nB" which will take just the name, or "%~pB" which will give the
path only, but say I want to remove the first character?

I know with Environment Variables I can do like the following to
remove just the first character, is there something like this for the
"%B" variable?:
set MYVAR=Hello.txt
echo %MYVAR:~1%


I'm using "cmd.exe" in Windows XP SP3. Thanks
 
NvrBst said:
FOR %B IN (*.*) echo "%B"

Is there any way to edit the %B variable? I know the basic ones like
"%~nB" which will take just the name, or "%~pB" which will give the
path only, but say I want to remove the first character?

I know with Environment Variables I can do like the following to
remove just the first character, is there something like this for the
"%B" variable?:
set MYVAR=Hello.txt
echo %MYVAR:~1%


I'm using "cmd.exe" in Windows XP SP3. Thanks

You have to assign its current value to an env. variable before removing the
first character:
set MyVar=%b
echo %MyVar:~1%
 
Back
Top