- Oct
- 35
- 0
How can I enumerate and work with an age range of files based in minutes? I'd like to be able to copy files from a directory based on being x minutes old.
By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!%@eval[(%@makeage[%_date,%_time] - %@fileage["%f"]) / 600000000=1]
%@eval[(%@makeage[%_date,%_time] - %@fileage["%f",,c]) / 600000000=1]
v:\> do f in n*.txt (echo %f is %@eval[(%@makeage[%_date,%_time] - %@fileage["%f"]) / 600000000=1] minutes old)
nowfile.txt is 12.1 minutes old
ntqip.txt is 646157.7 minutes old
function minutes_old `%@eval[(%@makeage[%_date,%_time] - %@fileage[%1]) / 600000000=1]`
if %@minutes_old[%filename] LT 10 ...
HELP DATERANGES
, you'll find this little nugget:Instead of a date, you can specify a file age for the first and/or second parameter.
set now=%@makeage[%_isodate,%_time]
set then=%@eval[%@makeage[%_isodate,%_time] - ( 5 * 60 * 10000000 )]
dir /a /[d%then]
That's good. I didn't mention ranges because of the problem of time ranges not going back into the previous day. That is, for example, /[t-60] doesn't work as might be desired between 00:00:00 and 00:59:59. Your method gets around that.Well, I just learned something I never knew. InHELP DATERANGES
, you'll find this little nugget:
So. To get the current time as an age:
Code:set now=%@makeage[%_isodate,%_time]
And to get five minutes ago as an age:
Code:set then=%@eval[%@makeage[%_isodate,%_time] - ( 5 * 60 * 10000000 )]
And then you can plug that right into a date range:
Code:dir /a /[d%then]
A user-defined function to convert n minutes ago to a file age would be trivial.