Script to copy file to unique file name

Discussion in 'Scripting' started by KatieMac, Aug 6, 2004.

  1. KatieMac

    KatieMac Guest

    I am looking to have a script (so I can automate through Windows Task
    Scheduler) that would copy a file out to a unique file name.

    So for instance, existing file is called "daily effort.htm".... This file
    gets overwritten each AM. Ideally, I would like to rename this file each
    night to mm-dd Daily effort.htm like 08-05 daily effort.htm.

    Thanks
     
    KatieMac, Aug 6, 2004
    #1
    1. Advertisements

  2. Hi Katie,

    This should work for you:

    ===========================================
    Set FsO = Wscript.CreateObject("Scripting.FileSystemObject")

    Filename = Date()

    FsO.CopyFile "c:\daily effort.htm", "c:\" & Filename & ".htm"

    Set FsO = Nothing

    WScript.Quit
    ===========================================

    Instead of the Copyfile method you can also use the MoveFile method.

    Regards

    Jan
     
    J.H.A. van de Weijer, Aug 6, 2004
    #2
    1. Advertisements

  3. or to get the format the OP wanted:

    sDate = Now
    Filename = Right("0" & Month(sDate), 2) & "-" _
    & Right("0" & Day(sDate), 2) & " daily effort.htm"
     
    Torgeir Bakken \(MVP\), Aug 6, 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.