How to set file Date/Time attributes from parts of filename

English support forum

Moderators: sheep, Hacker, Stefan2, white

FreeStyler
Junior Member
Junior Member
Posts: 3
Joined: 2019-12-29, 13:35 UTC

Re: Date/Time attributes from filename

Post by *FreeStyler » 2019-12-29, 16:55 UTC

Hi,
Colon ":" is a prohibited character in the file or folder name.
Try to create a new directory with the name ":", you will get an error.

User avatar
Stefan2
Power Member
Power Member
Posts: 2717
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Date/Time attributes from filename

Post by *Stefan2 » 2019-12-29, 16:59 UTC

JensusUT wrote:
2019-12-29, 16:37 UTC
...
I tried the multi-rename-string
[=tc.Name:7-8].[=tc.Name:5-6].[=tc.Name:1-4] [=tc.Name:9-10]:[=tc.Name:11-12]:[=tc.Name:13-14]

But as soon as I add the first colon to separate hours and minutes ([=tc.Name:9-10]:[=tc.Name:11-12]) I get an error


Where's the fault?



A colon ":" is an invalid sign for an file name (MRT is for to rename file names!)
So that is an hint of the MRT that the FILENAME on RENAMING would be invalid.

As you only want to use the MRT as an preview tool,
to build the string to modify the Date and Time attributes using elements taken from the file name (to other readers: see very first posting)
just let out that colons in the MRT and add them firstly in the Attribute dialogue.





 

JensusUT
Junior Member
Junior Member
Posts: 9
Joined: 2004-09-04, 21:06 UTC

Re: Date/Time attributes from filename

Post by *JensusUT » 2019-12-29, 17:08 UTC

Yeah, I know, but the preview in Multi-rename-tool is recommended by Christian as a check for the intended file attribute-change (file date based on file name)

I'm refering to this search result: https://ghisler.ch/board/viewtopic.php?p=323818#p323818 (sorry, the german part of the board).

Thanks,
Jensus

JensusUT
Junior Member
Junior Member
Posts: 9
Joined: 2004-09-04, 21:06 UTC

Re: Date/Time attributes from filename

Post by *JensusUT » 2019-12-29, 17:09 UTC

Ah, Stefan2, missed your reply!

I'll give it a try asap, thanks :)

@Edit: I's working :)! 658 pictures with the correct file-date in 20 sec, hiphip-huraaaayyyy!

User avatar
Usher
Power Member
Power Member
Posts: 706
Joined: 2011-03-11, 10:11 UTC

Re: Date/Time attributes from filename

Post by *Usher » 2019-12-29, 20:31 UTC

JensusUT wrote:
2019-12-29, 16:37 UTC
But as soon as I add the first colon to separate hours and minutes
Elementary, my dear Watson.
You can't use colon and some other characters in a filename in Windows.
https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words
Regards from Poland
Andrzej P. Wozniak

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 38731
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Date/Time attributes from filename

Post by *ghisler(Author) » 2019-12-30, 09:26 UTC

The fault is that colons aren't allowed in file names. Just use dots instead, e.g.
[=tc.Name:7-8].[=tc.Name:5-6].[=tc.Name:1-4] [=tc.Name:9-10].[=tc.Name:11-12].[=tc.Name:13-14]
Author of Total Commander
http://www.ghisler.com

jjk
Member
Member
Posts: 176
Joined: 2003-07-03, 10:41 UTC

Re: Date/Time attributes from filename

Post by *jjk » 2019-12-30, 17:35 UTC

Hi all
All this topic is interesting. I would also 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.
Why ? What can I do ?
Thanks in advance.

User avatar
Stefan2
Power Member
Power Member
Posts: 2717
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Date/Time attributes from filename

Post by *Stefan2 » 2019-12-30, 17:49 UTC

jjk wrote:
2019-12-30, 17:35 UTC
Hi all
All this topic is interesting. I would also 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.
Why ? What can I do ?
Thanks in advance.
See menu "Files > Change Attribute" how a date have to look like for your region setting.
Maybe you have to use an / instead of an dot? And take care on the right order: DMY, MDY.
Or you extract invalid parts from the name (5-6 ; 1-4) ? You can utilize the MRT to control that.




  

jjk
Member
Member
Posts: 176
Joined: 2003-07-03, 10:41 UTC

Re: Date/Time attributes from filename

Post by *jjk » 2019-12-30, 19:30 UTC

Thanks Stefan2, but
[=tc.Name:7-8].[=tc.Name:5-6].[=tc.Name:1-4] or [=tc.Name:7-8]/[=tc.Name:5-6]/[=tc.Name:1-4]
are working, so I suppose that "." or "/" are correct separators.
I tried also // as separator.
All is working while day is some pattern as [tc.Name:x-y], but nothing works if I replace that pattern by a constant as 01.
I don't get any error message, but resulting date is xx.dd.yyyy where xx is my day number, and mm.yyyy are erroneous month/years like 06.2007 or so.
When day number is [tc.Name:x-y], result is totally correct. But if day number is a constant, then month and year are false.
So an alternative is to insert "1" in front of filenames by MRT, then use [=tc.Name:1-1] to redate, and finally delete initial "1" by MRT. But that is very tedious.

Also I tried several other combinations as :
[01].[=tc.Name:5-6].[=tc.Name:1-4] or
1.[=tc.Name:5-6].[=tc.Name:1-4], even "1".[=tc.Name:5-6].[=tc.Name:1-4], and so on.
My regional settings are french ones, date format is dd/mm/yyyy.
I think that only first item (day) is faulting, neither month nor year.
Perhaps a bug of TC ?

Can you confirm or infirm, check at home on your PC ?
TIA

User avatar
Stefan2
Power Member
Power Member
Posts: 2717
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Menu "Files - Change attributes" > Set writedate Date/Time attributes from parts of filename

Post by *Stefan2 » 2019-12-30, 20:07 UTC

Ahh, I see, you are right.


With "Files - Change attributes" > "More attributes"
Select "tc - writedate" and enter [=tc.name:-8,2].[=tc.name:-11,2].[=tc.name:-16,4]
Works on file name "Xenius - La fascination de l’ivoire_Arte_2019_03_29_17_08.ext" >>> 29.03.2019

But "tc - writedate" and enter 01.[=tc.name:-11,2].[=tc.name:-16,4]
fails in a way as the resulting month and year is very different from the wanted one from the file name >>> 01.11.2002

Another test: "tc - writedate" with 01.02.1999 again works and set the date correct too >>> 01.02.1999


German / win7-32 / TC 9.21a-32








EDIT:

Explanation from ghisler(Author) - Author of Total Commander at https://ghisler.ch/board/viewtopic.php?p=367172#p367172
ghisler(Author) wrote:
2020-01-03, 11:22 UTC
by ghisler(Author) » Fri Jan 03, 2020 12:22
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 this post (click), as "tc.Name:999" will be empty)

" [=tc.Name:999]01. " have two/three purposes:
a) adds an leading "[" to enable the parsing,
and b) insert nothing as 999 is behind allowed name length and so point to nothing.
and c) enables us to insert a leading literal string additionally to parsed parts of file name.



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 "[")


- - -


Example use, taken from the questions above:


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", use as value: [=tc.name:-8,2].[=tc.name:-11,2].[=tc.name:-16,4]

Or for example with timestamp too>> [=tc.name:-8,2].[=tc.name:-11,2].[=tc.name:-16,4] 12:45:00



See menu "Files > Change Attribute" how a date have to look like for your region setting.
Or see "HKEY_CURRENT_USER\Control Panel\International\sShortDate + sShortTime"

Maybe you have to use an / instead of an dot to separate the date parts? And take care on the right order: DMY, MDY, YMD.

Code: Select all

United States of America	m/d/yy or m/d/yyyy
United Kingdom , Israel		dd/MM/yyyy
South Africa			yyyy/MM/dd
Hungary				yyyy.MM.dd
Germany; Poland, Norway		dd.mm.yyyy
Sweden , Albania		yyyy-MM-dd
El Salvador , Nicaragua		MM-dd-yyyy
South Korea			yyyy. M. d


Take care to extract the right parts from the name by [=tc.Name:X-Y]
Tip: Use the MRT (multi-rename tool) as an preview tool, to build that string using elements taken from the file name.
Press there in the MRT the F1-key and read more about the MRT "[N]-token" syntax and use that knowledge for [=tc.name: X Y] too.

But as soon as you would add the first colon in MRT to separate hours and minutes you will get an error.
     Because, an colon ":" is an invalid sign for an file name (remember: the MRT is for to rename file names!)
    So that is an hint of the MRT that the FILENAME on RENAMING would be invalid.
So just let out that colons in the MRT and add them firstly in the "Files - Change attributes"-dialogue.






- - -
 

jjk
Member
Member
Posts: 176
Joined: 2003-07-03, 10:41 UTC

Re: Date/Time attributes from filename

Post by *jjk » 2019-12-31, 14:05 UTC

To Christian :

an idea ? or a bug ?

User avatar
sqa_wizard
Power Member
Power Member
Posts: 3517
Joined: 2003-02-06, 11:41 UTC
Location: Germany

Re: Date/Time attributes from filename

Post by *sqa_wizard » 2020-01-01, 19:29 UTC

On "20191229_Xenius - La fascination de l’ivoire_Arte.ext"
Try it with doublequotes directly after "=" of first plugin entry:

"tc - writedate" and enter [="01."tc.Name:5-6].[=tc.Name:1-4]

This works at least for me :)
#5767 Personal license

User avatar
BlackWinny
Junior Member
Junior Member
Posts: 28
Joined: 2014-01-18, 16:10 UTC

Re: Date/Time attributes from filename

Post by *BlackWinny » 2020-01-02, 12:27 UTC

Hello !
JensusUT wrote:
2019-12-29, 16:37 UTC
Where's the fault?
FYI, I'm using 9.50ß10.

Kind regards, thanks and a nice day,

Jensus
The fault is simply that you want to use a colon (":") as separator.

It is forbidden by the operating system to use a colon (":") in the string of a filename or of a foldername.

Here are the reserved characters and words which are forbidden to use in filenames and foldernames :
Reserved characters and words

Just put any other separator of your convenience, as I do using "-" (a hyphen or a minus sign). You'll see... it works perfect.
:mrgreen:

Happy New Year !

User avatar
BlackWinny
Junior Member
Junior Member
Posts: 28
Joined: 2014-01-18, 16:10 UTC

Re: Date/Time attributes from filename

Post by *BlackWinny » 2020-01-02, 12:35 UTC

Ha Ha ! I had not seen that there were already many answers.
:lol:


Happy New Year anyway !
:mrgreen:

User avatar
Stefan2
Power Member
Power Member
Posts: 2717
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Date/Time attributes from filename

Post by *Stefan2 » 2020-01-02, 12:55 UTC

Hi wizard!
sqa_wizard wrote:
2020-01-01, 19:29 UTC
On "20191229_Xenius - La fascination de l’ivoire_Arte.ext"
Try "tc - writedate" and enter [="01."tc.Name:5-6].[=tc.Name:1-4]
Works for me too, good find, thanks for sharing!



 

Post Reply