Batch file help

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
3 answers Last reply
More about batch file help
  1. 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
  2. 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.
  3. 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%"
Ask a new question

Read More

Microsoft Zip Windows XP