Way to deal with empty tag values

Advanced Renamer forum
#1 : 27/03-16 16:46
Bruno G.
Bruno G.
Posts: 6
Hello,

Is there a way to deal with empty tag values? For example, I want to use the tag <ExifTool:DateTimeOriginal> to rename photos and movies in a folder, but the movies don't have this tag. So for those, I would like to use the file's date.

I would like to be able to say "Use this tag but if it's empty, use this other tag instead" for the "New Name" method.

By the way, Thanks for a great software ! :-)


27/03-16 16:46
#2 : 27/03-16 17:32
Bruno G.
Bruno G.
Posts: 6
Reply to #1:

Oh ! Just realized that there is Scripting (https://www.advancedrenamer.com/user_guide/examp le_scripting).

I'm a programmer, so I should be able to handle that ! :-)

...

For those interested, here is my solution, with the Script method:

var str = app.parseTags('<ExifTool:DateTimeOriginal>');
if (str === '') {
str = app.parseTags('<Year Created>_<Month Created>_<Day Created> <Hour Created>_<Min Created>_<Sec Created>');
}
return str;


27/03-16 17:32 - edited 27/03-16 17:55
#3 : 29/03-16 21:07
Kim Jensen
Kim Jensen
Administrator
Posts: 870
Reply to #2:
Scripting is not always ideal. It is more complicated and much slower than the native methods. I think it is a good idea to have a fallback tag when a tag value is empty. For an upcoming version of Advanced Renamer I will look into separating tags with | for tags your want to coalesce into one value.
That way you will be able to use the tags like this:
<ExifTool:DateTimeOriginal>|<ExifTool:FileModifyDate>
maybe even chaining multiple:
<ExifTool:DateTimeOriginal>|<ExifTool:CreateDate>|<ExifTool:FileModifyDate>


29/03-16 21:07
#4 : 09/04-16 21:08
Tuxster
Tuxster
Posts: 3
Reply to #3:
Just wanted to note that this would be an excellent solution to the problem, and I would love to see it implemented in the way suggested.



09/04-16 21:08
#5 : 15/04-16 12:41
Raskery
Raskery
Posts: 8
Reply to #3:

I agree this would be an excellent and very useful feature. Thanks.


15/04-16 12:41
#6 : 30/04-16 06:40
Jon
Jon
Posts: 1
Reply to #2:
For me, I found that the exifvalue "CreateDate" was more accurate for video dates. Using your same idea i came up with this:

var str = app.parseTags('<ExifTool:DateTimeOriginal>');
if (str === '') { //if str is blank get CreateDate, which is normally accurate for videos.
str = app.parseTags('<ExifTool:CreateDate>');
}
return str;


I would prefer to only have the YYY_MM_DD in my filename. Does anybody know an easy way to remove the HH_MM_SS? Currently I just add a remove rule after I put the date in to remove it, but I would prefer to handle it in the script if possible.


Thanks!


30/04-16 06:40 - edited 30/04-16 06:41
#7 : 10/06-16 18:49
Jeb Smith
Jeb Smith
Posts: 2
I just started using this program the other day and had to deal with a similar issue. I wanted to apply executable versions in the name. Since these fields are often neglected by developers when they compile it needed to be a little flexible.

Renaming method list example:

someapp1.exe
someapp2.exe
someapp3.exe

--> Add "((<ExifTool:FileVersion>))"

someapp1(()).exe
someapp2((1.2.9)).exe
someapp3(()).exe

If tag was blank, lets try next best one:
--> Replace "(())" with "((<ExifTool:ProductVersion>))"

someapp1((2.9.3)).exe
someapp2((1.2.9)).exe
someapp3(()).exe

Clear anything that didn't have a tag:
--> Replace "(())" with ""

someapp1((2.9.3)).exe
someapp2((1.2.9)).exe
someapp3.exe

Format files that had tags to taste:
--> RegEx Replace "(\(\()(.+)(\)\))" with ".v\2"

someapp1.v2.9.3.exe
someapp2.v1.2.9.exe
someapp3.exe

If I had to deal with more tags I would use something like "(a())", "(b())", "(c())" to have easy granular control.


10/06-16 18:49 - edited 10/06-16 18:57
#8 : 01/01-17 16:54
Knud
Knud
Posts: 1
Reply to #7:
Thanks for this solution.
Still it would be a very practical addition if a çoalesce method would be implemented (e.g. as <preferred>|<first alternative>|<second alternative>|... )


01/01-17 16:54
#9 : 15/10-17 11:08
Germo Görtz
Germo Görtz
Posts: 2
Reply to #3:
is there a time plan if and when this COALESCE method using "|" for alternative tags will be implemented?


15/10-17 11:08
#10 : 21/10-17 11:36
Brandon Earnhardt
Brandon Earnhardt
Posts: 4
Reply to #6:
I have something on GitHub but its more for photos:
https://github.com/bmearnhardt/advanced-renamer- photo-script

Basically it just takes the DateTimeOriginal which is just a string, and uses substrings to cut out what I want from it. I used this to make a format of like 'P 2017-10-21 18-20-16-86.jpg' for photos.


21/10-17 11:36
#11 : 22/10-17 23:36
MrHants
MrHants
Posts: 18
Reply to #10:

I'm no coder, but this could help to resolve the issue I have, where no date taken metadata exists, but still tries to rename the file based on a duplicate name appendage. Why not simply fail where the data doesn't exist if called for during a rename? Turning off the duplicate name suffix does then return a fail but only if the files are in same dir.

In a list of 10k files, I had a few hundred of these and they were scattered about with no way to group them together.

Such a great app and the scripting side looks so powerful, if only I understood how to use it, but I do like to tinker but must make sure I back up my files first!!!


22/10-17 23:36
#12 : 30/10-17 15:13
MrHants
MrHants
Posts: 18
Reply to #2:

Thanks for the script.. fixes the issue I was having with missing exif info!

Quick Q...

var str = app.parseTags('<ExifTool:DateTimeOriginal>');
if (str === '') {
str = app.parseTags('<Year Created>_<Month Created>_<Day Created> <Hour Created>_<Min Created>_<Sec Created>');
}
return str;


Ive replaced the _ with a - assuming this would then be reflected in the new filename, but it doesn't, is this not what its used for?

Thanks


30/10-17 15:13