Page 1 of 1

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

Posted: 2023-10-31, 20:56 UTC
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

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

Posted: 2023-11-01, 08:10 UTC
by ghisler(Author)
The multi-rename tool contains something similar in the [T] placeholder, e.g. [T1+60m].

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

Posted: 2023-11-03, 09:15 UTC
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.

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

Posted: 2024-01-18, 17:01 UTC
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)

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

Posted: 2024-01-19, 07:56 UTC
by ghisler(Author)
Please test it and let me know what you think!

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

Posted: 2024-01-19, 22:14 UTC
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)

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

Posted: 2024-01-21, 09:06 UTC
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.

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

Posted: 2024-01-21, 20:23 UTC
by hi5
That fixes it, thanks.

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

Posted: 2024-01-22, 08:43 UTC
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).

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

Posted: 2024-02-01, 07:31 UTC
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

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

Posted: 2024-02-01, 10:59 UTC
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.

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

Posted: 2024-02-01, 14:50 UTC
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.

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

Posted: 2024-02-02, 09:39 UTC
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.

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

Posted: 2024-02-02, 13:42 UTC
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.