• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Accessing OriginalRawFileName through xmp?

Explorer ,
Oct 01, 2019 Oct 01, 2019

Copy link to clipboard

Copied

Hi!

I am having trouble with accessing the XMP OriginalRawFileName - can anyone help me?

I need to be able to read what the original filename of a picture is, and figured this would be easiest to solve by looking at the xmp data, but I can't even read that properly - I am obviously doing something wrong.

 

SuperMerlin wrote this, and I tried just copy/pasting it - but I cannot get a result even from the unmodified original code;

 

#target photoshop;
if(documents.length){
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
var xmp = new XMPMeta(activeDocument.xmpMetadata.rawData); 
var shadow = xmp.getProperty(XMPConst.NS_CAMERA_RAW,"ParametricShadowSplit");
var exposureValue = xmp.getProperty(XMPConst.NS_CAMERA_RAW, "Exposure"); 
var keys = getArrayItems(XMPConst.NS_DC,'subject');
for(var a in keys){
    //amend the match for your keywod
    if(keys.toString().match(/key1/)){
        //things to do if keyword found
        alert("keyword found");
        break;
        }  
    }
};
function getArrayItems(ns, prop){
var arrItem=[];
var items = xmp.countArrayItems(ns, prop);
            for(var i = 1;i <= items;i++){
                    arrItem.push(xmp.getArrayItem(ns, prop, i));
                }
return arrItem;
};

 

 So - how would one modify the above (or write new code) to access the OriginalRawFileName?

Thank you in advance!

TOPICS
Actions and scripting

Views

791

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Oct 02, 2019 Oct 02, 2019

Copy link to clipboard

Copied

I'm guessing part of the answer may be:

 

(XMPConst.NS_CAMERA_RAW,"RawFileName")

 

However, I'm probably wrong.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 02, 2019 Oct 02, 2019

Copy link to clipboard

Copied

Well it's at least logical - but I don't know how to use it yet:/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 02, 2019 Oct 02, 2019

Copy link to clipboard

Copied

I just did a Batch Rename in Bridge with Preserve current filename checked. This is the tag and namespace. I'd look there.

xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"

<xmpMM:PreservedFileName>foo.CR2</xmpMM:PreservedFileName>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 02, 2019 Oct 02, 2019

Copy link to clipboard

Copied

RawFileName “naturally” exists in any file processed through ACR. PreservedFileName is obviously set by Bridge using the Batch Rename tool. What if a raw file has not been touched by either ACR or Bridge?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 02, 2019 Oct 02, 2019

Copy link to clipboard

Copied

The images will probably get handled via Bridge, but since I am buildning a script to handle everything automatically, I'd like to have it as a stand-alone function:/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 02, 2019 Oct 02, 2019

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 03, 2019 Oct 03, 2019

Copy link to clipboard

Copied

Yes!:) Great work you do over at PS-Scripts btw!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 03, 2019 Oct 03, 2019

Copy link to clipboard

Copied

I modified a script by Dan Ebberts found here.

 

It detects raw filename on jpgs saved from a RAW, but you need to open them manually - I cannot get it to work on the current file (activeDocument) though - will try to solve it tomorrow if I have time to have a look on it then...

Here's what I've got right now;

try {
	var metaFile = File.openDialog("Select file to import.");
	var xmpFile = new XMPFile( metaFile.fsName,  XMPConst.FILE_UNKNOWN, XMPConst.OPEN_FOR_READ);
	var xmp = xmpFile.getXMP();
	var RAWFileName = xmp.getProperty(XMPConst.NS_CAMERA_RAW,"RawFileName");
	try {
			alert("Found Raw Filename:\n" + RAWFileName.toString());
		} 
	catch(error) {
			alert("No Raw Filename could be found.");
		}
	} catch(error) {
		alert("Something seems to have gone wrong.\n" + error);
	}

 

 

 Thank you Stephen_A_Marsh for finding (XMPConst.NS_CAMERA_RAW,"RawFileName") for me!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 03, 2019 Oct 03, 2019

Copy link to clipboard

Copied

It is right there in the raw metadata of any file processed through ACR…Then it is just a matter of matching the name space. Of course, more than that is required but it was a start.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 03, 2019 Oct 03, 2019

Copy link to clipboard

Copied

Try this:

 

 

 

#target photoshop;  

//community.adobe.com/t5/Photoshop/Accessing-OriginalRawFileName-through-xmp/m-p/10647387#M266922
//Accessing OriginalRawFileName through xmp?

//estk.aenhancers.com/10%20-%20Scripting%20Access%20to%20XMP%20Metadata/accessing-the-xmp-scripting-api.html
//forums.adobe.com/message/10315559#10315559
//Help with script to read specific XMP metadata in an image - Credit to SuperMerlin
//community.adobe.com/t5/Photoshop/Help-with-script-to-read-specific-XMP-metadata-in-an-image/m-p/9859270#M169875
//community.adobe.com/t5/Photoshop/Help-with-script-to-read-specific-XMP-metadata-in-an-image/m-p/9859271#M169876

if(documents.length){  
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');  
var xmp = new XMPMeta(activeDocument.xmpMetadata.rawData);   
var RFN = xmp.getProperty(XMPConst.NS_CAMERA_RAW,"RawFileName");  
/////////////////// Do with as you wish  
alert(RFN);  
//////////////  
}

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 03, 2019 Oct 03, 2019

Copy link to clipboard

Copied

This is just brilliant. I guess I'll have to credit both you and SuperMerlin - thank you so much, it does exactly what I want!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 03, 2019 Oct 03, 2019

Copy link to clipboard

Copied

LATEST

My pleasure, it is a great way for me to learn! Here is a variation to remove the filename extension:

 

 

 

#target photoshop;  

//community.adobe.com/t5/Photoshop/Accessing-OriginalRawFileName-through-xmp/m-p/10647387#M266922
//Accessing OriginalRawFileName through xmp?

//estk.aenhancers.com/10%20-%20Scripting%20Access%20to%20XMP%20Metadata/accessing-the-xmp-scripting-api.html
//forums.adobe.com/message/10315559#10315559
//Help with script to read specific XMP metadata in an image - Credit to SuperMerlin
//community.adobe.com/t5/Photoshop/Help-with-script-to-read-specific-XMP-metadata-in-an-image/m-p/9859270#M169875
//community.adobe.com/t5/Photoshop/Help-with-script-to-read-specific-XMP-metadata-in-an-image/m-p/9859271#M169876

if(documents.length){  
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');  
var xmp = new XMPMeta(activeDocument.xmpMetadata.rawData);   
var RFN = xmp.getProperty(XMPConst.NS_CAMERA_RAW,"RawFileName");
// var RFN2 = RFN.toString().split(".", 1) // remove extension
var RFN2 = RFN.toString().replace(/\.[^\.]+$/, ''); // remove extension

/////////////////// Do with as you wish  
alert(RFN2);  
//////////////  
 
}

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines