get date to file

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Krynn
Posts: 10
Joined: Thu Jul 05, 2012 1:11 am

get date to file

Post by Krynn » Mon Nov 08, 2021 7:48 pm

Hello,

I would like to recover the creation date of a file.
I can get the date, but it is in the form of ticks. And I don't know how to convert it.

Code: Select all

put  files((fld "Chemin"), detailed) into field "listing"
set the itemdelimiter to ","
put item 4 of line 1 of field "listing" into TempsCreate
I can get the date with the shell, but as I have to do this for many files, it is too slow.

Do you have any idea how to do this?
thanks

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: get date to file

Post by FourthWorld » Mon Nov 08, 2021 9:12 pm

I suspect the slowest part of that is rendering the long file list in a field. If you don't need to display the list use a variable instead. If it's still too slow we can investigate further.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: get date to file

Post by dunbarx » Mon Nov 08, 2021 9:27 pm

Hi.

Not sure what your handler does, But you can convert the ticks to a date. Perhaps in a button script:

Code: Select all

on mouseUp
   get the ticks --returned by your handler
   divide it by 60
   convert it to  date
end mouseUp
"Convert" will not work directly on the ticks. We are changing those to the "seconds" You can convert also to "dateItems" which might give you even more information.

Craig

Krynn
Posts: 10
Joined: Thu Jul 05, 2012 1:11 am

Re: get date to file

Post by Krynn » Mon Nov 08, 2021 10:36 pm

"Convert" will not work directly on the ticks. We are changing those to the "seconds" You can convert also to "dateItems" which might give you even more information.

Craig
thank you very much, it works great
It seems so simple.


Time for 119 files:
- with shell: 34 secondes
- with convert date: 0.2 secondes.
Last edited by Krynn on Tue Nov 09, 2021 12:45 am, edited 2 times in total.

Krynn
Posts: 10
Joined: Thu Jul 05, 2012 1:11 am

Re: get date to file

Post by Krynn » Mon Nov 08, 2021 10:38 pm

FourthWorld wrote:
Mon Nov 08, 2021 9:12 pm
I suspect the slowest part of that is rendering the long file list in a field. If you don't need to display the list use a variable instead. If it's still too slow we can investigate further.
I have about 1000 files.
I already store in a variable.

The problem was the console that displays 1000x is about 1 second per file. that's what slows it down.
but thanks for your feedback

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: get date to file

Post by FourthWorld » Tue Nov 09, 2021 2:58 am

Krynn wrote:
Mon Nov 08, 2021 10:38 pm
FourthWorld wrote:
Mon Nov 08, 2021 9:12 pm
I suspect the slowest part of that is rendering the long file list in a field. If you don't need to display the list use a variable instead. If it's still too slow we can investigate further.
I have about 1000 files.
I already store in a variable.

The problem was the console that displays 1000x is about 1 second per file. that's what slows it down.
but thanks for your feedback
Happy to help. Thanks for confirming that the display rendering was the bottleneck.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: get date to file

Post by Klaus » Tue Nov 09, 2021 10:45 am

Hi Krynn,
Krynn wrote:
Mon Nov 08, 2021 7:48 pm
I can get the date, but it is in the form of ticks. And I don't know how to convert it.

Code: Select all

put  files((fld "Chemin"), detailed) into field "listing"
set the itemdelimiter to ","
put item 4 of line 1 of field "listing" into TempsCreate
...
to be precise:
The fourth item in the detailed file list is in SECONDS not ticks!


Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: get date to file

Post by dunbarx » Tue Nov 09, 2021 3:31 pm

Krynn.

Hmmm.

If Klaus is correct, then you do not need to convert. If you do, your dates will be rather older. :wink:

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7391
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: get date to file

Post by jacque » Tue Nov 09, 2021 6:10 pm

Klaus is right, see the dictionary.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: get date to file

Post by Klaus » Tue Nov 09, 2021 7:15 pm

Hi Craig,
dunbarx wrote:
Tue Nov 09, 2021 3:31 pm
If Klaus is correct...
sorry, don't understand!? 8)


Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: get date to file

Post by dunbarx » Tue Nov 09, 2021 7:39 pm

Klaus.

It means do you know what you are talking about. I get this all the time.

Craig

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: get date to file

Post by Klaus » Tue Nov 09, 2021 7:45 pm

dunbarx wrote:
Tue Nov 09, 2021 7:39 pm
Klaus.

It means do you know what you are talking about. I get this all the time.

Craig
:D :D :D

Post Reply