Batch file help

G

Guest

I've forgotten how to write simple batch files!
My backup program saves files to "datafile.zip".
I need a batch program that renames this file to "datafile 2005-06-10.zip"
or whatever today's date is on the date I run the program.

Is this the place to ask for help to write these few lines? If so, could
someone write them for me? Between the command prompt, the Properties icon
and the % parameters, I can't remember how to do it.

Thx
 
P

Pegasus \(MVP\)

JK said:
I've forgotten how to write simple batch files!
My backup program saves files to "datafile.zip".
I need a batch program that renames this file to "datafile 2005-06-10.zip"
or whatever today's date is on the date I run the program.

Is this the place to ask for help to write these few lines? If so, could
someone write them for me? Between the command prompt, the Properties icon
and the % parameters, I can't remember how to do it.

Thx

Try this:

@echo off
set FileName=%date:~4,10%
set FileName=DataFile %FileName:/=-%.zip
if exist %FileName% del %FileName%
ren datafile.zip "%FileName%"
 
D

Don Taylor

=?Utf-8?B?Sks=?= said:
I've forgotten how to write simple batch files!
My backup program saves files to "datafile.zip".
I need a batch program that renames this file to "datafile 2005-06-10.zip"
or whatever today's date is on the date I run the program.
Is this the place to ask for help to write these few lines? If so, could
someone write them for me? Between the command prompt, the Properties icon
and the % parameters, I can't remember how to do it.

Is this close enough?
Use Notepad or whatever else you prefer to create your little text
batch file somewhere in your path.

echo off
set MyDate=%date:/=-%
ren datafile.zip "datafile%MyDate%.zip"

To test that you can open up the command prompt.
You may also need to include a path to your datafile.zip,
it isn't clear where you want to put the batch file or
where that is in relation to your datafile.zip.

This should give you "datafile Fri 06-10-2005.zip",
for example. If that is close enough then you are done.

You can google with groups->advanced search in the
microsoft.public.windowsxp.general group for batch date
and find considerably more complicated batch files to
try to manipulate the format of dates.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top