I am trying to set a variable to the number of days since a log file was modified. this way I can use that value as a flag for the next time a command runs.
example:
if the command ran yesterday, the value will be 1
if the command ran 5 days ago, the value will be 5
I'm seeing methods for similar issues such as:
OR %%f IN (%filename%) DO SET filedatetime=%%~tf
or
if (file.exists()) {
Date lastModified = new Date(file.lastModified());
}
I just don't know batch scripting or powershell very well. I'm open to running this script in either. I think what I need to learn is:
1) extract the (tokens?) sub string of just the date from a date/time modified command
2) removing any colons or slashes
3) convert to an integer
4) repeat for today's date
Once I have two integers subtracting and setting a variable should be easy.
Any recommendations?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…