Answer» I need a windows batch FILE that I can RUN to look at log files and copy all files older than x days. I have alot of experience with UNIX scripting and know exactly how I would do it with shell scripting. I haven't done much scripting in the windows environment. I can't use WSL due to security reasons. Can someone please assist with this Thanks!RAM,
Try to realize that when batch language was introduced, date arithmetic was not high on the priority list. Sometimes its easier to back into this stuff. The script below copies the log files that you want to keep to a temporary directory, then deletes all the original log files and copies back the logs you want to keep.
@echo off set /P cutoffdate=Enter Cut Off Date (m-d-y) md c:\tempdirectory xcopy /d:%cutoffdate% yourdirectory\*.log c:\tempdirectory del yourdirectory\*.log copy c:\tempdirectory\*.log yourdirectory del \tempdirectory\*.* rd \tempdirectory set cutoffdate=
Feel free to change the directory names to fit your situation. Geez, this is one ugly script.
Good Luck.
|