Solved

WINXP SP3   DOS prompt  make directory

Posted on 2014-04-15
5
378 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 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

This is a little timesaver I have been using for setting up Microsoft Small Business Server (SBS) in the simplest possible way. It may not be appropriate for every customer. However, when you get a situation where the person who owns the server is i…
The password reset disk is often mentioned as the best solution to deal with the lost Windows password problem. In Windows 2008, 7, Vista and XP, a password reset disk can be easily created. But besides Windows 7/Vista/XP, Windows Server 2008 and ot…
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). …

790 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