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.
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
Answers (3)
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"
Comments:
-
didn't work - anonymous_148040 5 years ago
-
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" - SMal.tmcc 5 years ago
Comments:
-
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 ) - anonymous_148040 5 years ago
Can do this in PowerShell, guess you need it in VBS. - rileyz 5 years ago