Solved

WINXP SP3   DOS prompt  make directory

Posted on 2014-04-15
5
381 Views
Last Modified: 2014-04-15
Hi,

i using winxp sp3 's dos environment  , want to made sub-directory accroding to YYYYMMDD

here is command using at winsp2, new change to winxp sp3 environment , it seems not work :

md Y:\FoxproserverBackup\%date:~0,4%%date:~5,2%%date:~8,2%

what happened ?



Stanley
0
Comment
Question by:candychan611
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 84

Expert Comment

by:oBdA
ID: 40001185
Probably a new profile with new date format settings.
If the former command worked, you used a date format like YYYY/MM/DD (or some other separator than "/").
Check the output of
echo %date%

Open in new window

in a command prompt. You can then create the time stamp to your likings; the first of the two numbers after "%date:~" is the zero-based start index of the string you want to extract, the second one the number of characters, then follows the closing "%".
So if your date shows up as "04/14/2014", you'd use %date:~6,4%%date:~0,2%%date:~3,2% to get the YYYYMMDD format.
Or you can use a batch script that runs a WMI query, which doesn't depend on the date format:
@echo off
setlocal enabledelayedexpansion
set /a Line=0
for /f "tokens=1-9" %%a in ('wmic.exe Path Win32_LocalTime Get Day^,DayOfWeek^,Hour^,Minute^,Month^,Quarter^,Second^,WeekInMonth^,Year ^| find /v ""') do (
  set /a Line += 1
  if "!Line!"=="1" (set VarA=%%a&set VarB=%%b&set VarC=%%c&set VarD=%%d&set VarE=%%e&set VarF=%%f&set VarG=%%g&set VarH=%%h&set VarI=%%i)
  if "!Line!"=="2" (set !VarA!=%%a&set !VarB!=%%b&set !VarC!=%%c&set !VarD!=%%d&set !VarE!=%%e&set !VarF!=%%f&set !VarG!=%%g&set !VarH!=%%h&set !VarI!=%%i)
)
for %%a in (Month Day Hour Minute Second) do (if !%%a! LSS 10 set %%a=0!%%a!)
REM *** At this point, the variables Day, DayOfWeek, Hour, Minute, Month, Quarter, Second, WeekInMonth, and Year are set.
REM *** Month, Day, Hour, Minute, Second have leading zeros if less than 10.
set TimeStamp=%Year%%Month%%Day%
md Y:\FoxproserverBackup\%Timestamp%

Open in new window

0
 

Author Comment

by:candychan611
ID: 40001455
Hi oBDA,

Let me try    "%date:~6,4%%date:~0,2%%date:~3,2%" format  at  office tomorrow.

Can you provide some   reference book/site for the new syntax ?


Stanley
0
 
LVL 84

Accepted Solution

by:
oBdA earned 500 total points
ID: 40001467
It's not a new syntax, it's the definition of the date format, which is user dependent.
%Date% will have the format defined in "Short date" in Control Panel -> Region.
0
 

Author Comment

by:candychan611
ID: 40001515
oh ic ic
0
 

Author Comment

by:candychan611
ID: 40001543
The  XP SP3  regional setting is Hong Kong ,  

but  XP SP2 should be regional --- Taiwan .

So i will change to "Taiwan"  and  use the old  command:
md Y:\FoxproserverBackup\%date:~0,4%%date:~5,2%%date:~8,2%


Thanks for your help
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We have adopted the strategy to use Computers in Student Labs as the bulletin boards. The same target can be achieved by using a Login Notice feature in Group policy but it’s not as attractive as graphical wallpapers with message which grabs the att…
Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question