Sign in with
Sign up | Sign in
Your question

Batch file help

Last response: in Windows XP
Share
June 10, 2005 9:53:03 AM

Archived from groups: microsoft.public.windowsxp.general (More info?)

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

More about : batch file

Anonymous
June 10, 2005 11:28:12 AM

Archived from groups: microsoft.public.windowsxp.general (More info?)

Check out
http://users.cybercity.dk/~bse26236/batutil/batutil.htm
http://www.robvanderwoude.com/

Those two have lots of good info on them

mikey

"JK" <JK@discussions.microsoft.com> wrote in message
news:08768515-5062-4D95-873F-47351DAC3EB2@microsoft.com...
> 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
Anonymous
June 10, 2005 3:22:29 PM

Archived from groups: microsoft.public.windowsxp.general (More info?)

"=?Utf-8?B?Sks=?=" <JK@discussions.microsoft.com> writes:
>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.
Anonymous
June 11, 2005 4:30:19 AM

Archived from groups: microsoft.public.windowsxp.general (More info?)

"JK" <JK@discussions.microsoft.com> wrote in message
news:08768515-5062-4D95-873F-47351DAC3EB2@microsoft.com...
> 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%"
!