Dos Command

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All ,

How can I perform a dos command to copy 1.txt to 1 & [Date] & [Time].txt.
The [Date] And [Time] here means the current system date and time.
 
Travis said:
Hi All ,

How can I perform a dos command to copy 1.txt to 1 & [Date] & [Time].txt.
The [Date] And [Time] here means the current system date and time.

There is no way for a DOS command to do this. Fortunately
there is no DOS under WinXP. DOS is an operating system,
as is WinXP. You're probably thinking of the Command Prompt.

The WinXP Command Prompt is far more powerful than DOS.
Here is how you can run your command:

copy 1.txt "1 %date:/=-% %time::=-%.txt"

or perhaps like so:

@echo off
set d=%date:~4,10%
set t=%time:~0,5%
echo copy 1.txt "1 %d:/=-% %t::=-%.txt"
 
Travis said:
Hi All ,

How can I perform a dos command to copy 1.txt to 1 & [Date] & [Time].txt.
The [Date] And [Time] here means the current system date and time.

There is no way for a DOS command to do this. Fortunately
there is no DOS under WinXP. DOS is an operating system,
as is WinXP. You're probably thinking of the Command Prompt.

The WinXP Command Prompt is far more powerful than DOS.
Here is how you can run your command:

copy 1.txt "1 %date:/=-% %time::=-%.txt"

or perhaps like so:

@echo off
set d=%date:~4,10%
set t=%time:~0,5%
echo copy 1.txt "1 %d:/=-% %t::=-%.txt"

Hallo!
Just jumping in.
I need the date in reverse order i.e. 20060409 or 2006-04-09.
How to achieve that? Thanks!
Helge
 
Helge Haensel said:
Travis said:
Hi All ,

How can I perform a dos command to copy 1.txt to 1 & [Date] & [Time].txt.
The [Date] And [Time] here means the current system date and time.

There is no way for a DOS command to do this. Fortunately
there is no DOS under WinXP. DOS is an operating system,
as is WinXP. You're probably thinking of the Command Prompt.

The WinXP Command Prompt is far more powerful than DOS.
Here is how you can run your command:

copy 1.txt "1 %date:/=-% %time::=-%.txt"

or perhaps like so:

@echo off
set d=%date:~4,10%
set t=%time:~0,5%
echo copy 1.txt "1 %d:/=-% %t::=-%.txt"

Hallo!
Just jumping in.
I need the date in reverse order i.e. 20060409 or 2006-04-09.
How to achieve that? Thanks!
Helge

You could use this two-line batch file:
@echo off
for /F "tokens=2-4 delims=/ " %%a in ('echo %date%') do copy 1.txt "1
%%c-%%b-%%a.txt"

It relies on your date being shown as Son 09/04/2006 which
is probably correct since you appear to be in Germany. If it
does not work then please post the output you get when you
run this command in a Command Prompt:
echo %date% %time%
 
Am 09.04.2006, 11:20 Uhr, schrieb Pegasus (MVP) <[email protected]>:

You could use this two-line batch file:
@echo off
for /F "tokens=2-4 delims=/ " %%a in ('echo %date%') do copy 1.txt "1
%%c-%%b-%%a.txt"

It relies on your date being shown as Son 09/04/2006 which
is probably correct since you appear to be in Germany. If it
does not work then please post the output you get when you
run this command in a Command Prompt:
echo %date% %time%
Germany is ok!
echo %date% %time% returns 09.04.2006 11:50:56,91
So your example doesnt work.
In the meantime i tweaked a little bit around and found
set "d=%date:~6,4%%date:~3,2%%date:~0,2%"
seems to work for me. Is the syntax acceptable?
Is there some documentation available?
Thanks!
Helge
 
Helge Haensel said:
Am 09.04.2006, 11:20 Uhr, schrieb Pegasus (MVP) <[email protected]>:


Germany is ok!
echo %date% %time% returns 09.04.2006 11:50:56,91
So your example doesnt work.
In the meantime i tweaked a little bit around and found
set "d=%date:~6,4%%date:~3,2%%date:~0,2%"
seems to work for me. Is the syntax acceptable?
Is there some documentation available?
Thanks!
Helge

Your syntax uses substrings, which is perfectly OK.
My syntax uses tokens. It would have to be modified
like so to work:
for /F "tokens=1-3 delims=." usw.

You can get full documentation by typing for /? at the
Command Prompt.
 
Your syntax uses substrings, which is perfectly OK.
My syntax uses tokens. It would have to be modified
like so to work:
for /F "tokens=1-3 delims=." usw. Works.

You can get full documentation by typing for /? at the
Command Prompt.
Thanks!
Have a nice weekend.
Helge
 
Back
Top