I could easily figure out how to do this if I could use Excel and VBA, but my requirement is to create a batch file that will reference some kind of parameter or initialization file. I’m hoping one of my fellow MrExcel fans will have some serious .bat skills that I can learn from.
Here is what I need to accomplish. I have a number of log files that occasionally get too large. I would like to take each of these and rename that file with some kind of date stamp indicator. Then I need to create or replace that log file with an empty file of the original name. This batch file would be triggered only when the services and processes have been stopped for system backups or patching, so nothing would be actively writing to the files. The idea is that the parameter file would be a list of all the files that need to be managed by this batch.
For instance:
Current file - C:\test\toofull.log
The renamed file - C:\test\toofull_20130926.log
Create an empty file called - C:\test\toofull.log
I’m thinking that the batch file will drive the action with code that says something like:
For %%A in (FileList.txt) DO
NAME strFileName AS Replace(strFileName, ".", Format(Now(), "_yyyymmdd") & ".")
NAME C:\blank.log AS strFileName
The parameter file might contain a list that looks like:
K:\Test\EventLog.log
D:\Data\errorfileload.log
S:\Logs\IntlLoad.log
M:\Automation\Import.log
I’m certainly open to suggestions! And this could probably benefit from error handling but not sure what that would look like.
Appreciate any guidance or direction you can offer.
Here is what I need to accomplish. I have a number of log files that occasionally get too large. I would like to take each of these and rename that file with some kind of date stamp indicator. Then I need to create or replace that log file with an empty file of the original name. This batch file would be triggered only when the services and processes have been stopped for system backups or patching, so nothing would be actively writing to the files. The idea is that the parameter file would be a list of all the files that need to be managed by this batch.
For instance:
Current file - C:\test\toofull.log
The renamed file - C:\test\toofull_20130926.log
Create an empty file called - C:\test\toofull.log
I’m thinking that the batch file will drive the action with code that says something like:
For %%A in (FileList.txt) DO
NAME strFileName AS Replace(strFileName, ".", Format(Now(), "_yyyymmdd") & ".")
NAME C:\blank.log AS strFileName
The parameter file might contain a list that looks like:
K:\Test\EventLog.log
D:\Data\errorfileload.log
S:\Logs\IntlLoad.log
M:\Automation\Import.log
I’m certainly open to suggestions! And this could probably benefit from error handling but not sure what that would look like.
Appreciate any guidance or direction you can offer.