Scripting Question

Can anyone help me to create vbscript for copying a file from one folder to another folder and then rename the copied file by appending date and time to the file name.

07/06/2019 722 views

I need to copy my server log file to another folder up on completion of one log file and then rename the copied file adding date and time to the file name

Source : C:\\Server\Logs

Destination : Can be selected by user using .BrowseForFolder

Log file name : Server_logs_23.txt("23" is the log number which will change from 1 to 30)

One log file will be completed in 2 minutes and log writing will be moved to next file by adding one(that means if Server_logs_23.txt is completed then server will starts writing logs in Server_logs_24.txt  till Server_logs_30.txt, if log is completed then it will starts writing in log_1)

Below is the flow chat fr the script log_1 

2 Comments   [ + ] Show comments


  • Sounds like a school assignment, lol.
    Can do this in PowerShell, guess you need it in VBS.
  • Thank you for making it simple as school assignment. First of all I am not an expert in coding(If I am , i wont ask here). I need this in Vbscript or atleast in batch

Community Chosen Answer


Batch with user input:

set /p Input=Enter destination path:
move install.log "%Input%\install_%date:~-4,4%%date:~-7,2%%date:~-10,2%_.log"

command line:
move install.log "c:\someplaceelse\install_%date:~-4,4%%date:~-7,2%%date:~-10,2%_.log"

Answered 07/08/2019 by: SMal.tmcc
Red Belt

  • didn't work
    • Oops I forgot time, what else does not work?
      move c:\temp\install.log "c:\temp\tempmove\install_%date:~-4,4%%date:~-7,2%%date:~-10,2%_%time:~0,2%_%time:~3,2%.log"

All Answers


Answered 07/09/2019 by: SMal.tmcc
Red Belt

  • this will move only one file, i need to move multiple files according to my input.

    For example I will input a string "log_12" , code should search for that string in list of files in the source folder and if a match found then copy that file to another location with date and time. This process should be continuous(means it should be in loop until i stop it )

how about this then

do a batch with input for target

rename Install_*.log "Install_*_%date:~-4,4%%date:~-7,2%%date:~-10,2%_%time:~0,2%_%time:~3,2%.log"

move *.log %1

Answered 07/11/2019 by: SMal.tmcc
Red Belt

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:


This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ