Way to deal with empty tag values

Advanced Renamer forum
#1 : 27/03-16 16:46
Bruno G.
Bruno G.
Posts: 2
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: 2
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: 734
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