[REQ] How to avoid name clashes in MRT?

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
TLis
Member
Member
Posts: 111
Joined: 2004-06-02, 16:48 UTC
Location: Szczecin, Poland

[REQ] How to avoid name clashes in MRT?

Post by *TLis »

Hi,

When I am downloading the images from my camera, I use the MRT with the Exif plugin to rename them to <year>-<month>-<day>_<hour><minutes><seconds>.jpg.

Unfortunately, if I am making serial pictures (e.g. 10 shots taken one after another with the delay of a fraction of a second), this would result in some files getting the same names, as these pictures were taken within the same second.

TC then correctly detects the name clashes, and warns the user, asking whether to proceed or not. Of course, I don't want to lose my pictures, so I answer No, redo the file selection for MRT, avoiding the duplicates, and then try again, until there are no name clashes.

After doing this basic rename operation, I load the remaining files in sets consisting of pictures taken within the same second, and use MRT to rename them using the pattern <year>-<month>-<day>_<hour><minutes><seconds>_<counter>.jpg. Usually I have then about 3-4 files in each of such sets. You can imagine, how tedious it becomes, if I have really many serial pictures to process ...

I am looking for a way to let TC handle such duplicates automatically. Apart from existing options telling TC to go ahead, or to cancel the operation, TC could offer some kind of additional automatic renaming scheme. I think, that the most popular option would be to add an additional counter part to the already formed target file name with a separator. The counter in question should be an independent counter from the one already used in MRT. It should restart automatically from its starting value for each set of conflicting names. It could be coded as the lowercase [c] with all the arguments already supported by [C].

Example (file name and the exif time and date)
1.jpg - 24/05/2007 16:51:00
2.jpg - 24/05/2007 16:52:00
3.jpg - 24/05/2007 16:53:00
4.jpg - 24/05/2007 16:53:00
5.jpg - 24/05/2007 16:53:00
6.jpg - 24/05/2007 16:54:00
7.jpg - 24/05/2007 16:54:00
8.jpg - 24/05/2007 16:54:00
9.jpg - 24/05/2007 16:54:00
10.jpg - 24/05/1007 16:55:00

Then I use MRT with the renaming pattern [=exif.DateOriginal.Y-M-D]_[=exif.TimeOriginal.hms] for the name part. TC would detect the name clashes on some of the files (files 3, 4, 5 and 6, 7, 8, 9), offering an additional rename by appending a suffix to the file name. I would then choose the suffix to be e.g. _[c1+1:2] (note lowercase 'c'), and TC would produce the following names:

1.jpg - 2007-05-24_165100.jpg

2.jpg - 2007-05-24_165200.jpg

3.jpg - 2007-05-24_165300_01.jpg
4.jpg - 2007-05-24_165300_02.jpg
5.jpg - 2007-05-24_165300_03.jpg

6.jpg - 2007-05-24_165400_01.jpg
7.jpg - 2007-05-24_165400_02.jpg
8.jpg - 2007-05-24_165400_03.jpg
9.jpg - 2007-05-24_165400_04.jpg

10.jpg - 2007-05-24_165500.jpg

What do you think about it?
User avatar
TLis
Member
Member
Posts: 111
Joined: 2004-06-02, 16:48 UTC
Location: Szczecin, Poland

Post by *TLis »

Don't you have any comments on this enhancement, or how it could be done better? If not, maybe there are other tools, that could help me in the picture file renaming?

Could an extension help here?
User avatar
Hacker
Moderator
Moderator
Posts: 13067
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Hm, only thing that comes to mind would be to extract the exif info into a file (containing the desired filenames) and then check it for duplicate filenames, appending some numbers as in your example, per script. Could auto-rename the files as well. The tricky part would be to extract the exif data with the source filename into the file. The rest is easy.

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.
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

I could offer a (quite simple) batch solution, with has some drawbacks compared to your suggestion:
  • based on file system date/time, not on EXIF information
  • no seconds, only hour/minute
  • appending the original filename in every case, not only on duplicate files
  • the year is only stored with two digits (07 instead of 2007; a fixed leading "20" can be added in the batch though)
  • padding of leading zeros to filename would have to be done with MRT before (to avoid order 1,10,11,2,3,4,...)
  • order of year/month/date is depending on your local system settings
    (the batch might have to be adjusted to your settings)
So the result would be like

Code: Select all

1.jpg   =>  2007-05-26_2249_1.jpg
10.jpg  =>  2007-05-26_2250_10.jpg  
2.jpg   =>  2007-05-26_2249_2.jpg  
3.jpg   =>  2007-05-26_2249_3.jpg  
4.jpg   =>  2007-05-26_2249_4.jpg  
5.jpg   =>  2007-05-26_2250_5.jpg  
6.jpg   =>  2007-05-26_2250_6.jpg  
7.jpg   =>  2007-05-26_2250_7.jpg  
8.jpg   =>  2007-05-26_2250_8.jpg  
9.jpg   =>  2007-05-26_2250_9.jpg
Would that help?

If you can extract the EXIF information to a file (like Hacker suggested), this could probably be used, too.
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
User avatar
Hacker
Moderator
Moderator
Posts: 13067
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

TLis,
You could also try using JHead with the -n[<fmt-string>] option. BTW, it can also be used to extract the timestamp, so I can try and create a script. :)

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.
User avatar
Hacker
Moderator
Moderator
Posts: 13067
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Hm, finding duplicate lines is more difficult than I thought. :( This is where I got:

Code: Select all

RunWait, %comspec% /c jhead *.* >> TempExifDataFile.txt
FileRead, ExifData, TempExifDataFile.txt
FileDelete, TempExifDataFile.txt
Loop, Parse, ExifData, `n, `r
{
	IfInString, A_LoopField, File name    :%A_Space%
	{
		StringReplace, Name, A_LoopField, File name    :%A_Space%
		NamesAndDates = %NamesAndDates%ren "%Name%"
		StringGetPos, DotPos, Name, ., R
		Extension := SubStr(Name, DotPos+2)
	}

	IfInString, A_LoopField, File date    :%A_Space%
	{
		StringReplace, Date, A_LoopField, File date    :%A_Space%
		StringSplit, DateValues, Date, :%A_Space%
		Year = %DateValues1%
		Month = %DateValues2%
		Day = %DateValues3%
		Hour = %DateValues4%
		Minute = %DateValues5%
		Second = %DateValues6%
		NamesAndDates = %NamesAndDates%*"%Year%-%Month%-%Day%_%Hour%%Minute%%Second%.%Extension%"`r`n
	}
}
So we have a file in the format

Code: Select all

ren <oldname>*<newname>
Duplicates might be easier to find after exchanging the format to

Code: Select all

<newname>*ren <oldname>
by checking the part up to the "*". However, it is difficult to work with separate lines / entries, and the conversion to an array proves difficult. :(

So, if anyone likes to continue, I'd be glad to learn.

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.
User avatar
TLis
Member
Member
Posts: 111
Joined: 2004-06-02, 16:48 UTC
Location: Szczecin, Poland

Post by *TLis »

Thank you all very much for all your comments. It seems, that it is not as simple, as I have thought, so instead of enhancing the MRT tool, I started thinking of writing a specific program doing, what I need.

I have found the lst2str add-on, which would pass the names of the selected files on the command line to whatever program I write. I feel fairly comfortable with the Python language scripting, so I think, I will write a script performing all the rename operation instead of MRT. If you are interested, I will publish it when completed.

Update: In fact, lst2str may be not needed, as I may encounter limitations of the command-line length. My script can easily read the file created by %L, which will overcome the difficulty.
User avatar
RID500
Member
Member
Posts: 194
Joined: 2006-11-20, 12:38 UTC

Post by *RID500 »

2TLis
for this more advantages renaming i have Siren in my TC folder.

In Siren you wrote %Xdt%ncs.%e


"Siren Help"

Code: Select all


%Xdt : DateTime from the  Group of "exif" information

%nc  : the selection number relative to a name "collision"  (same beginnings)

          for example, with the expression: %dmd_%nc.%e
          File           Modif date     Result
          Image1.jpg     01/01/2004     20040101_001.jpg
          Image2.jpg     12/12/2004     20041212_001.jpg
          Image3.jpg     01/01/2004     20040101_002.jpg
          Image4.jpg     12/12/2004     20041212_002.jpg
          Image5.jpg     12/12/2004     20041212_003.jpg


%ncs : same principle as "%nc" except that it is empty for
          the first element of the "collision group" and prefixed
          by a "_" for the others.

          for example, with the expression: %dmd%ncs.%e
          File           Modif date     Result
          Image1.jpg     01/01/2004     20040101.jpg
          Image2.jpg     12/12/2004     20041212.jpg
          Image3.jpg     01/01/2004     20040101_001.jpg
          Image4.jpg     12/12/2004     20041212_001.jpg
          Image5.jpg     12/12/2004     20041212_002.jpg

%e   : the name extension
With Siren you can store this expression as favorite
and start Siren with this favorite as parameter.
To use this for all selected files in TC read an How To here ==> http://scarabee.software.free.fr/forum/viewtopic.php?id=89
No installation needed, unzip and run. ~900 kB (300 UPX)
Siren stores it settings into an ini file. Freeware.
For more details just download Siren at http://www.scarabee-software.net/en/siren.html
/join #TCMD Chat at irc.freenode.net - Today's newbies are tomorrow's experts.
User avatar
TLis
Member
Member
Posts: 111
Joined: 2004-06-02, 16:48 UTC
Location: Szczecin, Poland

Post by *TLis »

Thanks, RID500, I will take a look at Siren.

Since we are going a bit off topic, I would like to leave a slight improvement suggestion for the MRT tool in TC. If duplicates are found, the dialog warning about this fact could offer an option to REMOVE the files causing the duplicate names from the list of files to be removed, and proceed with the rest. This would save me (or other users) from having to reselect manually the files for MRT until all duplicates are removed. I hope, that the improvement in the form proposed above is general enough, so that it would serve not only the picture file renaming, but also other uses.

It could be implemented as putting a flag /IGNORE/ on specific elements of the original list, so that they are NOT processed. This would help to be consistent with other proposed features, like the support of the list of target names to be used for rename, etc. :-)
Post Reply