Luis Diaz
asked on
Windows batch: append log files based on datestamp
Hello experts,
I have the following procedure which allows me to append log files on specific folder:
I would like to add the following requirements
-Be able to report a date stamp to append based on this date
Example:
DateStamp: 15
Append files newer or equal than 15 days.
If you have questions, please contact me.
I have the following procedure which allows me to append log files on specific folder:
@echo off
setlocal
set BaseDir=B:\EE\EE29154094\Files
set MergeFile=B:\EE\EE29154094\merge.csv
echo.filename;datemodified;content>"%MergeFile%"
for %%A in ("%BaseDir%\*.*") do (
if /i NOT "%%~A" == "%MergeFile%" (
for /f "tokens=*" %%B in ('type "%%~A"') do (
echo.%%~nxA;%%~tA;%%B>>"%MergeFile%"
)
)
)
I would like to add the following requirements
-Be able to report a date stamp to append based on this date
Example:
DateStamp: 15
Append files newer or equal than 15 days.
If you have questions, please contact me.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you, I will test proposals and keep you informed.
ASKER
@Bill:
I tested your proposal and I got files with the following date: 05/08/2019 13:24:00 with KeepDays=1.
When I run date I have the following: The current date is: 11/09/2019
Thank you for your help.
I tested your proposal and I got files with the following date: 05/08/2019 13:24:00 with KeepDays=1.
When I run date I have the following: The current date is: 11/09/2019
Thank you for your help.
ASKER
Strange, I'm certain I tested that before on W10, but indeed FORFILES is not able to show files newer than a past date. /d +3 shows files which are changed 3 days in the future from now - that really makes no sense :-/
ASKER
Thank you for your feedback.
Potential workaround:
Potential workaround:
- Create a temp folder within merge folder
- Transfer the files newer than past day
- Create the merge file with the required information
- Remove temp folder
Sorry, small typo in my earlier post, I corrected in that post now.
»bp
»bp
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Noted, Thank you. I will retest both proposals and keep you informed.
ASKER
Tested and it works!
Thank you for you help!
Thank you for you help!
Open in new window