PDA

View Full Version : DOS copy command with date stamp


greg w
November 24th 04, 05:33 PM
Hi,

I would like to have somefile.txt be copied into somefile.txt.112404 so
that I can archive the file. I would prefer to do this in DOS and not
VBScript or WSH. Any suggestions?

Thanks in advance, Greg

Rich McKinney
November 24th 04, 06:33 PM
Greg,

add this to the batch file:
FOR /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
set My_DayOfWeek=%%i
set My_Month=%%j
set My_Day=%%k
set My_Year=%%l
)

Then you can use the SET variables above to name the files in any order you
want to use such as:
COPY somefile.txt somefile%day%%month%%year%.txt

Hope this helps

Rich





"greg w" wrote:

> Hi,
>
> I would like to have somefile.txt be copied into somefile.txt.112404 so
> that I can archive the file. I would prefer to do this in DOS and not
> VBScript or WSH. Any suggestions?
>
> Thanks in advance, Greg
>
>

greg w
November 24th 04, 06:38 PM
here's what i found that works great!

for /F "tokens=2-4 delims=/- " %%A in ('date/T') do set mdate=%%A%%B%%C
copy somefile.txt somefile%mdate%.txt

greg w
November 24th 04, 06:38 PM
here's what i found that works great!

for /F "tokens=2-4 delims=/- " %%A in ('date/T') do set mdate=%%A%%B%%C
copy somefile.txt somefile%mdate%.txt

Google