none
vbscript to copy file to another folder by taking backup of old file RRS feed

  • Question

  • Hi Guys..

    Can you help me out ..

    I vant to move the file named as RAJA from c drive to d drive.

    now i want to take a bac-up of existing file raja in d-drive vith a date(for example file name is raja it should become raja18-12-2013(today's date) )

    am getting upto copying the file from c to d . but it is replacing the existing file. so help me out. please ???

    Wednesday, December 18, 2013 1:53 PM

Answers

All replies

  • Rename the file on D: before copying the current file to that drive.

    Bill

    Wednesday, December 18, 2013 3:23 PM
    Moderator
  • Hallo,

    Here is the code:

    option explicit

    Dim fileSystem, Fso, mydate
    mydate = date
    Set Fso = WScript.CreateObject("Scripting.FileSystemObject")
    Fso.CopyFile "d:\test\RAJA.txt", "d:\test\RAJA"&mydate&".txt"

    Set fileSystem = CreateObject("Scripting.FileSystemObject")

    filesystem.CopyFile "c:\test\raja.txt", "d:\test\"

    WScript.Echo "done"


     Regards, Azzim

     

    Wednesday, December 18, 2013 4:03 PM