Source language: Translate to:

Age of File

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Age of File

Postby ajhunt » Fri Oct 23, 2015 7:52 am

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.
ajhunt
 
Posts: 221
Joined: Sat Apr 23, 2005 2:33 pm
Location: United Kingdom

Re: Age of File

Postby HPW » Fri Oct 23, 2015 9:33 am

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
Hans-Peter
User avatar
HPW
 
Posts: 2516
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: Age of File

Postby mishem » Fri Oct 23, 2015 10:52 am

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.
mishem
 
Posts: 575
Joined: Mon Oct 08, 2012 1:51 pm

Re: Age of File

Postby Gaev » Fri Oct 23, 2015 12:59 pm

@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.
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Age of File

Postby ajhunt » Thu Oct 29, 2015 4:02 am

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.
ajhunt
 
Posts: 221
Joined: Sat Apr 23, 2005 2:33 pm
Location: United Kingdom

Re: Age of File

Postby dpayer » Thu Oct 29, 2015 8:14 am

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.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1382
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 2 guests