Help - Search - Members - Calendar
Full Version: CMD script help please
The CD Forum > After Hours > Rest of the World
Ed_P
I'm sure I'm missing something simple but for the life of me I don't see it.

When I run this code
CODE
setlocal
FOR /F "tokens=1-4 delims=/ " %%I IN ('DATE /t') DO (
  set MM=%%J
  set DD=%%K
  set YY4=%%L)
echo on
set YY = %YY4:~2,2%
echo YY4 = %YY4%
echo YY = %YY%
@echo off


I see in the Command Prompt window
CODE
D:\My Documents\My Utilities>set YY = 08

D:\My Documents\My Utilities>echo YY4 = 2008
YY4 = 2008

D:\My Documents\My Utilities>echo YY =
YY =

Why isn't the set YY = %YY4:~2,2% taking???? mad.gif
d4vr0s
It works for me if I remove the spaces in the YY = %YY4:~2,2%
CODE
set YY=%YY4:~2,2%
Ed_P
Thank you worthy.gif d4vr0s.

I knew it would be something simple that I was missing. blushing.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.