%$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)
Moderators: Hacker, petermad, Stefan2, white
%$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)
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
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)
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
- ghisler(Author)
- Site Admin
- Posts: 50386
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)
The multi-rename tool contains something similar in the [T] placeholder, e.g. [T1+60m].
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)
It will be nice if you can add this to the "Change plugin attributes" of the "Change attributes" dialog.The multi-rename tool contains something similar in the [T] placeholder, e.g. [T1+60m].
Currently there is no way to change the date or time of files and folders by an offset.
Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)
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)
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
- ghisler(Author)
- Site Admin
- Posts: 50386
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)
Please test it and let me know what you think!
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)
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)
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)
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
- ghisler(Author)
- Site Admin
- Posts: 50386
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)
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.
%|$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
https://www.ghisler.com
Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)
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)
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
- ghisler(Author)
- Site Admin
- Posts: 50386
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)
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
https://www.ghisler.com
Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)
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
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
- ghisler(Author)
- Site Admin
- Posts: 50386
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)
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.
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
https://www.ghisler.com
Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)
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.
The numeric field will be separated from the text field by a colon.
- ghisler(Author)
- Site Admin
- Posts: 50386
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)
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
https://www.ghisler.com
Re: %$DATE:placeholders%: Add an offset option (Seconds, Minutes, Hours, or Days)
2ghisler(Author)
Now everything is fine with the dash.
Fixed in 11.03RC4, thank you!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)
Now everything is fine with the dash.