insert date into file name in batch file ...

Discussion in 'Scripting' started by E-Double, May 19, 2004.

  1. E-Double

    E-Double Guest

    (not sure if this is the correct forum for this post, but ...) Is there a way to substitute the date for a filename in a batch file ? For example, to copy filename.txt to date.txt ( where date is the date ). TI
     
    E-Double, May 19, 2004
    #1
    1. Advertisements

  2. Hi,

    Do you mean something like this ?

    Dim oFSO


    Set oFSO=CreateObject("scripting.filesystemobject")
    oFSO.CopyFile "Path to file to copy","c:\" & Replace(Date,"/","") & ".txt"

    Regards

    Niclas Lindblom
     
    Niclas Lindblom, May 20, 2004
    #2
    1. Advertisements

  3. E-Double

    UberSchnell Guest

    When you refer to Batch file do you mean DOS or are you working on a Windows NT/2K/XP CMD environment

    I couldn't work out how to do it in DOS but in CMD you should be able to use the following..

    Copy MyTextFile.txt "%Date%.txt"

    If someone knows how to get the date into an environment variable in DOS then you could effectively use the same command

    of course if you are working in VBS then Niclas Lindblom's reply is A-OK

    Cheers
     
    UberSchnell, May 21, 2004
    #3
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.