Solved

WINXP SP3   DOS prompt  make directory

Posted on 2014-04-15
5
374 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
  • 3
  • 2
5 Comments
 
LVL 83

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 83

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

cPanel is a Unix based web hosting control panel that provides a graphical interface and automation tools designed to simplify the process of hosting a web site. cPanel utilizes a 3 tier structure that provides functionality for administrators, rese…
Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

914 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now