Page 1 of 1

Age of File

PostPosted: Fri Oct 23, 2015 7:52 am
by ajhunt
Hi guys, I'm doing a small application for photos but only want to view photos which are not more than 3 hours old from the current time in the folder. Is there a plugin/action command I don't know about which will give me the age of a file in hours and minute (or just hours if minutes not possible). Thanks all for any suggestions.

Re: Age of File

PostPosted: Fri Oct 23, 2015 9:33 am
by HPW
Hello,

Depends on how much files are in the folder you could do a 'FileList' and with the recently added 'hpwGetFileDate' from hpwUtility you can do the math on the date and time in a loop.
Larger numbers of files may give problems.

Regards

Re: Age of File

PostPosted: Fri Oct 23, 2015 10:52 am
by mishem
math on the date and time

And so why complicate things?
You can also make the list. And three hours later another one, and compare them.

Re: Age of File

PostPosted: Fri Oct 23, 2015 12:59 pm
by Gaev
@mishem:

You can also make the list. And three hours later another one, and compare them.

Not very practical if you want to repeatedly check (say) every minute or so.

@ajhunt:

1) How many files do you expect to meet your criteria on average ? ... 10 ? ... 100 ? ... 1,000 ?

2) Note that the following DOS command (which you can invoke via NeoBook's Run command) will cut down on the list of matching files (if that is an issue) ...
Code: Select all
dir c:\myfolder\subfolder\*.jpg  /A-D /O-D > c:\myfolder\subfolder\filelist.txt


a) > c:\myfolder\subfolder\filelist.txt will place the "list of matching files present in the requested folder" into a text file (in this case filelist.txt).

b) /A-D will only list files (not directories).

c) /O-D will list the files in reverse order of date ... so you can stop processing the text file (via FileRead) when the first file with "timestamp older than 3 hours" is found.

Re: Age of File

PostPosted: Thu Oct 29, 2015 4:02 am
by ajhunt
Thanks guys for all the replys but was just hoping an action or script already existed so not having to do any maths. Really seeking something that would just give me how old a file was from the current hour and the current minute. i.e. like file is 2 hours old. I'll have a go and won't give up lol. Thanks again for the suggestions.

Re: Age of File

PostPosted: Thu Oct 29, 2015 8:14 am
by dpayer
Another one to add to the mix 8)

http://www.neosoftware.com/community/vi ... hp?t=19558

This is a project I did which employed a function I created from NB/VB scripts which can give you details on a file. You can look at the function and see if it might be helpful for your purposes.