Adding text if EXIF data not found

Advanced Renamer forum
#1 : 28/11-22 22:26
Alex
Alex
Posts: 2
Hi,

I'm renaming some JPGs in an effort to eventually sort out duplicates, so I'm thinking to rename the files based on the model of the camera used in the EXIF data and then ad some random numbers to avoid duplicate names.

Some JPGs don't have EXIF data, so if there's not EXIF data then there can be no model, so if there's no model I'd like to add text like "No EXIF data".

So two example JPGs would like this:

Nikon D100 56213211.jpg
No EXIF data 2325254.jpg

Thanks for any help.

The significance of using EXIF data is that I will eventually sort the JPGs into folders based on date taken.


28/11-22 22:26
#2 : 28/11-22 23:55
David Lee
David Lee
Posts: 1125
It's probably simplest to use a Script method.
Try:

camera = app.parseTags("<ExifTool:Make> <ExifTool:Model> ");
if (camera == " ") camera = "No EXIF data ";
return (camera) + item.newBasename;


28/11-22 23:55
#3 : 29/11-22 00:06
Alex
Alex
Posts: 2
Reply to #2:
Thanks very much, that looks like it'll work.

I've seen you contribute alot to this forum, could I make one more request?

Would it be possible to then move those files into folders based on the camera model or into a folder named "No EXIF Data" if there is no EXIF data?

I can move them into a folder if the data exists, but don't know how if it does or does not.


29/11-22 00:06
#4 : 29/11-22 11:30
David Lee
David Lee
Posts: 1125
Reply to #3:

Easy!

camera = app.parseTags("<ExifTool:Make> <ExifTool:Model>");
if (camera == " ") camera = "No EXIF data";
item.newPath = item.path + camera + "\\";
return (camera) + " " + item.newBasename;

Folders will be created if they don't already exist and will be located within the original folder containing the files.

Alternatively you can specify the folder location explicitly - but be aware that you need to replace "\" in the pathname with "\\" when using a script.

eg

item.newPath = "c:\\myfolder\\" + camera + "\\";


29/11-22 11:30 - edited 29/11-22 11:42