/build/static/layout/Breadcrumb_cap_w.png
07/06/2019 264 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

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

1


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

0


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 )
0

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