How to Send F5 to TC from my program (see inside)

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

It isn't wrong that OS doesn't keep timestamps, it shouldn't. However you can easilly copy timestamps after copying, you only need recursive enumeration procedure.
eitang
Senior Member
Senior Member
Posts: 250
Joined: 2003-05-19, 20:08 UTC
Location: France
Contact:

Post by *eitang »

MVV,

>> only need recursive enumeration procedure

Indeed. I have written, a long time ago a program that recurses through a directory tree and redates every folder to the same date as the "youngest" file in it (=most recent). It was not easy for me at all...
Best Wishes,

Eitan Gilboa (License #: 17011)
URL: https://eitang.pagesperso-orange.fr/
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

It may be not so easy for the first time, but algorithm is easy and procedure is simple: enumerate all items, call procedure for folders to enumerate files in them, and keep min date and compare all other with it...
User avatar
Hacker
Moderator
Moderator
Posts: 13142
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Sample AHK code:

Code: Select all

Loop, c:\*.*, 2, 1
{
	Loop, %A_LoopFileLongPath%\*.*
	{
		FileGetTime, TimeStamp
		FileDateList = %FileDateList%%TimeStamp%`n
	}
	Sort, FileDateList, R
	RegExMatch(FileDateList, "^.*?\n", NewestTimeStamp)
	IfNotEqual, NewestTimeStamp
		FileSetTime, %NewestTimeStamp%
	FileDateList =
}
:)
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
eitang
Senior Member
Senior Member
Posts: 250
Joined: 2003-05-19, 20:08 UTC
Location: France
Contact:

Post by *eitang »

MVV,

Tanks, I have done recursive programming, but not too much. Indeed results are amazing (code size).

Hacker,

Thanks for popping in and for the AHK routine.

I did "play" with AHK a long time ago (67yo) but stopped.

Seeing your compact code, I will consider returning to it... Tha point is that I really love Delphi...

Do I read correctly that there is a built-in function "NewestTimeStamp" ??? Unbelievable.
Best Wishes,

Eitan Gilboa (License #: 17011)
URL: https://eitang.pagesperso-orange.fr/
eitang
Senior Member
Senior Member
Posts: 250
Joined: 2003-05-19, 20:08 UTC
Location: France
Contact:

Post by *eitang »

Hacker,

I am AMAZED !!! I DL'ed installed and used AHK with your code and it worked. This is wonderful. I even tried AHK2EXE with success. So now I will open the Help file <G> and read a little.

Many many thanks again.
Best Wishes,

Eitan Gilboa (License #: 17011)
URL: https://eitang.pagesperso-orange.fr/
User avatar
Hacker
Moderator
Moderator
Posts: 13142
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Hello eitang,
Glad it worked fine. :)
Do I read correctly that there is a built-in function "NewestTimeStamp" ???
Not really, that is just the name of a variable I used.

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
eitang
Senior Member
Senior Member
Posts: 250
Joined: 2003-05-19, 20:08 UTC
Location: France
Contact:

Post by *eitang »

Hacker,

>> Not really, that is just the name of a variable I used.

OK. Coming from Delphi and not C familly, I have great difficulty with the very shortened code... I am used to declaring variables, so something like this:

Code: Select all

RegExMatch(FileDateList, "^.*?\n", NewestTimeStamp)


is difficult to understand for me.

Anyway I made a little AHK program around tour routine that takes a folder and an extension as commandline params and does a lot more than my previous program...

Added an error message and default parameters, and changed your lines into:

Code: Select all

Loop, %1%\*.*, 2, 1 ; Folder
{
   Loop, %A_LoopFileLongPath%\*.%eg_ext%  : extension
*
*
}
Compiled into a stand alone EXE and shrinked with an EXE shrinker, it makes a great utility !

Many thanks.
Best Wishes,

Eitan Gilboa (License #: 17011)
URL: https://eitang.pagesperso-orange.fr/
User avatar
Hacker
Moderator
Moderator
Posts: 13142
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

eitang,
Coming from Delphi and not C familly
I am also coming from Delphi. ;)
Glad you're enjoying AHK and finding it useful. The Help file for AHK is one of the best Help resources for any program I have seen, it should be able to help you find your way round.

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
eitang
Senior Member
Senior Member
Posts: 250
Joined: 2003-05-19, 20:08 UTC
Location: France
Contact:

Post by *eitang »

Hacker,

>> The Help file for AHK ... it should be able to help you find your way round.

It already did, thank you!

Which version of Delphi was your las one ? (I am still with 5, because it is largely sufficient for my needs, and because of all the components that would not work on later versions...
Best Wishes,

Eitan Gilboa (License #: 17011)
URL: https://eitang.pagesperso-orange.fr/
eitang
Senior Member
Senior Member
Posts: 250
Joined: 2003-05-19, 20:08 UTC
Location: France
Contact:

Post by *eitang »

2Hacker

Please excuse me for a tech question: In the code you gave above

Code: Select all

Loop, c:\*.*, 2, 1
{
   Loop, %A_LoopFileLongPath%\*.*
   {
      FileGetTime, TimeStamp
      FileDateList = %FileDateList%%TimeStamp%`n
   }
   Sort, FileDateList, R
   RegExMatch(FileDateList, "^.*?\n", NewestTimeStamp)
   IfNotEqual, NewestTimeStamp
      FileSetTime, %NewestTimeStamp%
   FileDateList =
}
The line where you fill up the list:

Code: Select all

FileDateList = %FileDateList%%TimeStamp%`n
is totally opaque to me... I presume that FileDateList is the name of the list (containing files*.* in the currently treated folder).

I don't understant how the = sign adds items ???

I understand that `n is newline, so also is a new item, but the = ??? how comes it is not += or something like that? I didn't find anything about adding to lists other than GUI, and you do not use GUI..

TIA,
Best Wishes,

Eitan Gilboa (License #: 17011)
URL: https://eitang.pagesperso-orange.fr/
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I don't know AHK syntax but I guess mentioned line is an assignment, and it assigns concatenation of previous list value with current timestamp and line break, so in total it produces multi-line string with timestamps.
eitang
Senior Member
Senior Member
Posts: 250
Joined: 2003-05-19, 20:08 UTC
Location: France
Contact:

Post by *eitang »

MVV,

Thanks for the reply.

>> I guess mentioned line is an assignment,
Indeed, but an assignment (as I said in my Q. above) replaces the current contents. This list is a list of files in a directory, so can contain many lines. AHK has also a := assignment but it is not a sort of "add" items.

>> and it assigns concatenation
??
This may be true (I just started learning AHK yesterday...) but surprising.

>> in total it produces multi-line string with timestamps.
Indeed the 'n is a chr(13) [ and 'L is chr(10) ] so I understood the idea, but still, I don't understand the = <BG>
Best Wishes,

Eitan Gilboa (License #: 17011)
URL: https://eitang.pagesperso-orange.fr/
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I would say it looks like this in Delphi:

Code: Select all

FileDateList := FileDateList + TimeStamp + #13;
eitang
Senior Member
Senior Member
Posts: 250
Joined: 2003-05-19, 20:08 UTC
Location: France
Contact:

Post by *eitang »

Exactly, MVV.

Your code ADDS an item to an existing list.

In AHK above the list seems to get re-created every time from scratch, but with a carriage return hanging at its end <VBG>

Of course, the code is actually 100% working, and the problem is only my understanding of it...
Best Wishes,

Eitan Gilboa (License #: 17011)
URL: https://eitang.pagesperso-orange.fr/
Post Reply