%$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

%$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)

Post by *hi5 »

Since 11.00 beta 3 we have the special pseudo environment variable %$DATE:placeholders%.

It wouldn't be too difficult to add an offset option to allow "time shifting" by adding a "value" and "timeunit" like so (the | is probably no the best character as it is also used in %|envvar| but just for illustration).

%$DATE:placeholders|value|timeunit%

value: has to be a number (digit)
timenunit: one of these Seconds, Minutes, Hours, or Days (or S,M,H,D).
(Just like the TimeUnits of the AutHotkey https://www.autohotkey.com/docs/v1/lib/EnvAdd.htm command).

So now we can calculate next week: |7|Days
or two weeks ago: |-14|Days
or one hour ago: |-1|H

This is just a suggestion.
I've added this to my F4MM script
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)

Post by *ghisler(Author) »

The multi-rename tool contains something similar in the [T] placeholder, e.g. [T1+60m].
Author of Total Commander
https://www.ghisler.com
yong
Member
Member
Posts: 110
Joined: 2009-05-20, 07:23 UTC

Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)

Post by *yong »

The multi-rename tool contains something similar in the [T] placeholder, e.g. [T1+60m].
It will be nice if you can add this to the "Change plugin attributes" of the "Change attributes" dialog.
Currently there is no way to change the date or time of files and folders by an offset.
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)

Post by *hi5 »

11.03 release candidate 1 (RC1) wrote: * Pseudo environment variable %$DATE% now supports an offset, e.g. %$DATE+1Y% (use %|$DATE+1Y| in parameters field)
Last edited by hi5 on 2024-01-23, 20:56 UTC, edited 1 time in total.
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)

Post by *ghisler(Author) »

Please test it and let me know what you think!
Author of Total Commander
https://www.ghisler.com
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)

Post by *hi5 »

The date/time calculations seem to work in my testing so far, but I think when using %|$DATE|% there is a bug.
It seems to remove the first character after the ending % sign. This can be made visible by using a ? in the param field to show the date.
I use a 2 day offset here just for testing, but you should be able to see the . (dot) before the 7z ext is not there:

command: 7za
param: ?u %|$DATE:YMD-2D|%.7z *.*

result --> u 202401177z *.*
(notice no .7z)

when you add a space after the ending %

param: ?u %|$DATE:YMD-2D|% .7z *.*

result --> u 20240117.7z *.*
(notice it now says .7z)
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)

Post by *ghisler(Author) »

Sorry, that's just a typo in the documentation. The correct syntax would be with just one percent sign:
%|$DATE:YMD-2D|.7z

Reason: % placeholders in the parameters field only use a single % sign per placeholder, e.g. %P would be the current path.
%| is used for environment variables, and the placeholder ends with the next vertical line | and not with |%.
So that extra % would be combined with the dot to %. which has no meaning and would be removed.

I will fix the documentation.
Author of Total Commander
https://www.ghisler.com
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)

Post by *hi5 »

That fixes it, thanks.
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)

Post by *ghisler(Author) »

Great, thanks! I will fix the help file and history in RC2 (I already fixed it on the homepage and in the forum).
Author of Total Commander
https://www.ghisler.com
sa16
Senior Member
Senior Member
Posts: 217
Joined: 2021-09-10, 07:15 UTC

Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)

Post by *sa16 »

A small problem.
The variable %|$DATE:D.M.y_h-m-s| produces a different result from the previous version:

TC11.02
01.02.24_10-15-02

TC11.03RC1-RC3
01.02.24_10
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)

Post by *ghisler(Author) »

Confirmed, thanks.
The reason is that + and - are now used to add/subtract an offset, e.g. -1h would subtract one hour from the date value. But fortunately this is easy to detect, there just needs to be a number between 1 and 9 after the dash.
Author of Total Commander
https://www.ghisler.com
sa16
Senior Member
Senior Member
Posts: 217
Joined: 2021-09-10, 07:15 UTC

Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)

Post by *sa16 »

Maybe it will be more convenient to use %|$DATE-2D:YMD| instead of %|$DATE:YMD-2D|?
The numeric field will be separated from the text field by a colon.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)

Post by *ghisler(Author) »

The : is also often used in time formats (not in file names, of course) so I would prefer having only directly after the $DATE string.
Author of Total Commander
https://www.ghisler.com
sa16
Senior Member
Senior Member
Posts: 217
Joined: 2021-09-10, 07:15 UTC

Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)

Post by *sa16 »

2ghisler(Author)
01.02.24 Fixed: Pseudo environment variable %$DATE% no longer worked with dashes in format string, e.g. %$DATE:D.M.y_h-m-s% because the dash was used for an offset like %$DATE-1h% (32/64)
Fixed in 11.03RC4, thank you!
Now everything is fine with the dash.
Post Reply