renaming a file with the xmp file

Advanced Renamer forum
#1 : 11/09-21 02:26
Posts: 2
I have been tagging some files with F-Stop from android and it creates a XMP file as a side car to the original file.

Is it possible to rename the original image/movie file with the <ExifTool:Subject> from its side car (XMP)?

How do we go about doing that?

11/09-21 02:26
#2 : 12/09-21 18:20
David Lee
David Lee
Posts: 777
The obvious solution would appear to be "Pair renaming" however it is unpredictable which files will be treated as the source and which the pairs and in general it will rename the metadata file to match the media file.

I solve this problem using a script method.

Assume for example that you wish to rename a mixture of .avi, .mov and .jpg files and each has a corresponding .xmp file with the corresponding filename.

Add all your media files and the corresponding .xmp files to the List

Open a Script method and select Apply to: name and extension

In the Prebatch script enter the code:

var files = {};
count = app.itemCount;
for (j=0; j<count; j++) {
item = app.getItem(j);
ext = item.ext.toLowerCase();
if (ext == ".avi" || ext == ".mov" || ext == ".jpg"){
filename = + ext;
files[filename] = j;

and in the main script window enter:

if (item.ext.toLowerCase() == '.xmp') {
if (newName = app.parseTags("<ExifTool:Subject>")) {
if (files[ +".avi"]) app.getItem(files[ +".avi"]).newName = newName + ".avi";
if (files[ +".mov"]) app.getItem(files[ +".mov"]).newName = newName + ".mov";
if (files[ +".jpg"]) app.getItem(files[ +".jpg"]).newName = newName + ".jpg";
return newName;

To change the media filetypes edit the if statement in the Pre batch script:
if (ext == ".avi" || ext == ".mov" || ext == ".jpg")

"||" means "OR" so just add additional || ext == "filetype" elements as appropriate

and add corresponding lines in the main script:
if (files[ +".file"]) app.getItem(files[ +".filetype"]).newName = newName + ".filetype";

12/09-21 18:20 - edited 12/09-21 22:05