Dating files by change attributes / Set date timestamp from part of filename

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
jjk
Member
Member
Posts: 181
Joined: 2003-07-03, 10:41 UTC

Dating files by change attributes / Set date timestamp from part of filename

Post by *jjk »

To change date by some filename substrings, I use for example :
[=tc.Name:7-8].[=tc.Name:5-6].[=tc.Name:1-4] [=tc.Name:9-10].[=tc.Name:11-12].[=tc.Name:13-14]
It's OK.
But now I want to apply the first day of month to each file, because files are monthly and not day-dated.
I tried
01.[=tc.Name:5-6].[=tc.Name:1-4]
but it is not working.
Each time I use some constant instead or expression as [tc.Name:x-y], result is erratic.
See viewtopic.php?f=3&t=52215&start=15#p366971

Unfortunately, same in 9.5 beta 10.
User avatar
sqa_wizard
Power Member
Power Member
Posts: 3854
Joined: 2003-02-06, 11:41 UTC
Location: Germany

Re: Dating files by change attributes

Post by *sqa_wizard »

Try it with doublequotes directly after "=" of first plugin entry:
[="01."tc.Name:5-6].[=tc.Name:1-4]

This works at least for me :)
#5767 Personal license
jjk
Member
Member
Posts: 181
Joined: 2003-07-03, 10:41 UTC

Re: Dating files by change attributes

Post by *jjk »

Thanks, but no, result for
dd.[=tc.Name:5-6].[=tc.Name:1-4] 00.00.00
where dd is a constant between 01 and 31 is dd/05/2006 00:00
And results are the same with or without time indication.

But
[=tc.Name:5-6].mm.[=tc.Name:1-4] or [=tc.Nom:3-4].[=tc.Nom:7-8].yyyy
where mm is a constant between 01 and 12 and yyyy is a correct year number gives correct result.

It is as if only day as constant gives wrong results, but nor for month neither year as constants.
jjk
Member
Member
Posts: 181
Joined: 2003-07-03, 10:41 UTC

Re: Dating files by change attributes

Post by *jjk »

sqa_wizard wrote: 2020-01-01, 16:25 UTC Try it with doublequotes directly after "=" of first plugin entry:
[="01."tc.Name:5-6].[=tc.Name:1-4]

This works at least for me :)
Bingo, sga_wizard. It is working here also.
A big thank.
And sorry : in my previous post I answered to your first answer (deleted by you). Nevertheless I keep that post to show accurately to Christian where is the mistake. So, now Christian has to right that little bug when he has time to do. :D
User avatar
Hacker
Moderator
Moderator
Posts: 13040
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: Dating files by change attributes

Post by *Hacker »

jjk,
Does perhaps "1" work instead of "01"?

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.
jjk
Member
Member
Posts: 181
Joined: 2003-07-03, 10:41 UTC

Re: Dating files by change attributes

Post by *jjk »

Hacker wrote: 2020-01-01, 20:20 UTC jjk,
Does perhaps "1" work instead of "01"?
No, doesn't work. Always same result : 01/05/2006
And if I use the constant dd as day number (first date field), result is dd/05/2006
User avatar
petermad
Power Member
Power Member
Posts: 14700
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Dating files by change attributes

Post by *petermad »

I noticed that if I try to set both date and time like:

Code: Select all

01.[=tc.Name:5-6].[=tc.Name:1-4] [=tc.Name:9-10].[=tc.Name:11-12].[=tc.Name:13-14]
its does not work, but if I remove the space before the time value ( [=tc.Name:9-10] ) it works:

Code: Select all

01.[=tc.Name:5-6].[=tc.Name:1-4][=tc.Name:9-10].[=tc.Name:11-12].[=tc.Name:13-14]
EDIT: :!:
It is not correct that it works without the space - It just doesn't give an error message - it does set the date to 01, but the month and year is not set correctly.
Last edited by petermad on 2020-01-03, 14:06 UTC, edited 2 times in total.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
jjk
Member
Member
Posts: 181
Joined: 2003-07-03, 10:41 UTC

Re: Dating files by change attributes

Post by *jjk »

petermad wrote: 2020-01-02, 22:27 UTC if I remove the space before the time value ( [=tc.Name:9-10] ) it works:

Code: Select all

01.[=tc.Name:5-6].[=tc.Name:1-4][=tc.Name:9-10].[=tc.Name:11-12].[=tc.Name:13-14]
Unfortunately, not here (TC 9.10-64 -Win 10-64 v1809). Always same result : 01/05/2006, and time is not set (or not changed), on NTFS and Fat32 drives.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48012
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Dating files by change attributes

Post by *ghisler(Author) »

The attributes dialog only looks for placeholders when the first character is a "[". This is done because some fields like comments accept any kind of characters, so [ would be prefectly OK in a comment.
Author of Total Commander
https://www.ghisler.com
jjk
Member
Member
Posts: 181
Joined: 2003-07-03, 10:41 UTC

Re: Dating files by change attributes

Post by *jjk »

Thanks Christian
but I don't understand what you mean.
If I enter "01/02/2009" as value attribute of tc module, it is OK.
So any value can be a constant, not necessarly a placeholder.

Anyway, will it be possible to use 01.[=tc.Name:5-6].[=tc.Name:1-4] or still mandatory to use [="01."tc.Name:5-6].[=tc.Name:1-4] ?
User avatar
Stefan2
Power Member
Power Member
Posts: 4124
Joined: 2007-09-13, 22:20 UTC
Location: Europa

menu "Files - Change attributes" > Set tc.writedate to value from file name

Post by *Stefan2 »

jjk wrote: 2020-01-03, 12:15 UTC Thanks Christian
but I don't understand what you mean.
...


I understood it like this :

ghisler(Author) wrote: 2020-01-03, 11:22 UTC The attributes dialog only looks for placeholders when the first character is a "[".
This is done because some fields like comments accept any kind of characters, so [ would be prefectly OK in a comment.

So, an used "[=tc.Name:5-6].[=tc.Name:1-4]"-part is only evaluated, IF the very first sign in that box is an "[" sign.


So this works:
Example Name: "Xenius - La fascination de l’ivoire_Arte_2019_03_29_17_08.ext"

01/02/2009 (no evaluation/expanding need at all) >>> Set writedate to 02.01.2019 (depending on region, here US?)
03.02.2020 (German format) >>> Set writedate to 03.02.2019
[=tc.Name:7-8].[=tc.Name:5-6].[=tc.Name:1-4] (very first sign is an "[") >>> Set writedate to 29.03.2019
[="01."tc.Name:5-6].[=tc.Name:1-4] >>> Set writedate to 01.03.2019 (trick by sqa_wizard, an literal "01." before placeholder)
[=tc.Name:999]01.[=tc.name:-11,2].[=tc.name:-16,4] >>> Set writedate to 01.03.2019 (trick by ghisler(Author) in post below, as "tc.Name:999" will be empty)


This fails to expand the "tc.Names"-parts, because there is no leading "["to switch into that evaluation mode:
01.[=tc.Name:5-6].[=tc.Name:1-4] (very first sign is NOT an "[")



Right?




Example for other readers:
Example Name: "Xenius - La fascination de l’ivoire_Arte_2019_03_29_17_08.ext" >>> Set writedate to 29.03.2019
Utilize "Files - Change attributes" > "More attributes"
Select "tc - writedate" and enter [=tc.name:-8,2].[=tc.name:-11,2].[=tc.name:-16,4]
Taken from: viewtopic.php?f=3&t=52215&start=15#p366971





 
User avatar
Hacker
Moderator
Moderator
Posts: 13040
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: Dating files by change attributes

Post by *Hacker »

^

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.
jjk
Member
Member
Posts: 181
Joined: 2003-07-03, 10:41 UTC

Re: Dating files by change attributes

Post by *jjk »

OK. I understand now.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48012
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Dating files by change attributes

Post by *ghisler(Author) »

Yes, exactly. Something like this should work:
[=tc.Name:256]01.[=tc.Name:5-6].[=tc.Name:1-4] [=tc.Name:9-10].[=tc.Name:11-12].[=tc.Name:13-14]

because [=tc.Name:256] would be empty.
Author of Total Commander
https://www.ghisler.com
User avatar
Stefan2
Power Member
Power Member
Posts: 4124
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Dating files by change attributes

Post by *Stefan2 »

ghisler(Author) wrote: 2020-01-06, 09:19 UTC Yes, exactly. Something like this should work:
[=tc.Name:256]01.[=tc.Name:5-6].[=tc.Name:1-4] [=tc.Name:9-10].[=tc.Name:11-12].[=tc.Name:13-14]

because [=tc.Name:256] would be empty.

Thanks, that works.


Example Name: "Xenius - La fascination de l’ivoire_Arte_2019_03_29_17_08.ext"
[=tc.Name:999]01.[=tc.name:-11,2].[=tc.name:-16,4] >>> Set writedate to 01.03.2019




 
Post Reply