#1 : 11/12-22 03:14 Singapore
Posts: 3
|
Is it possible to rename the img file using metadata from the associated xmp file?
For instant, my subject tag is saved within the xmp file. Image 1.jpg Image 1.xmp (metadata of Monkey is inside here) I want to rename Image 1 to Monkey. Is this possible? |
#2 : 11/12-22 12:19 David Lee
Posts: 1125
|
It should be possible using pairing where paired files are renamed to match the new name of the primary file. Unfortunately the order of pairing is hard-coded so that you can only match an xmp file to match a jpg and not the other way round.
However you can solve your problem using a custom script. I'm assuming the new filename is in an Exif tag in the xmp file <Exif:MonkeyTag> - edit the tag name as appropriate... Prebatch script: var files = {}; count = app.itemCount; for (j=0; j<count; j++) { item = app.getItem(j); ext = item.ext.toLowerCase(); if (ext == ".jpg"){ files[item.name + ext] = j; } } Main script: if (item.ext == '.xmp') { newName = app.parseTags("<Exif:MonkeyTag>"); if (isFinite(files[item.name + ".jpg"])) { n = files[item.name + '.jpg']; app.getItem(n).newName = newName + ".jpg"; } return newName; } The Pre batch script runs once before the batch is executed and scans though all the filenames in the list. The object "files[]" stores a list of all jpg files together with their index numbers in the list. (The files[] object works like an array, storing the index numbers, except that the "array index" is a string (the filename) instead of an integer). When the main script runs it will skip over all files except .xmp files. If it finds an .xmp file it will extract the data from your desired tag. If there is a matching .jpg file in the files[] object then the jpg file is retrieved and renamed accordingly. Finally the same name is returned by the script to rename the .xmp file. |