Solved

WINXP SP3   DOS prompt  make directory

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

Expert Comment

by:oBdA
Comment Utility
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
Comment Utility
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 82

Accepted Solution

by:
oBdA earned 500 total points
Comment Utility
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
Comment Utility
oh ic ic
0
 

Author Comment

by:candychan611
Comment Utility
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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup". After a while, you have entered a loop for Auto repair which does not fix anything and you will be in a  panic as all your work w…
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…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…

743 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

10 Experts available now in Live!

Get 1:1 Help Now