I am looking for a script can check Physical file id of a document and compare it to another one. For example, I have some images named xxx_01.tif, xxx_02.tif... (they already had their own Raw data), I always need to save as a swatch (named xxx_sw.tif) from xxx_01 file to keep the Raw data but sometimes I created from xxx_02 and it didn't match.
Is there any way to check and alert if "Physical file id" of sw file doesn't match to 01's ?
Reply @GhoulFool:
var srcDoc = app.activeDocument;
var ctpath = srcDoc.path;
var ctname = srcDoc.name
var rawData1 = srcDoc.xmpMetadata.rawData;
var idCT = find_original_document_ID(rawData1);
function find_original_document_ID(str)
{
var regEx = new RegExp(".+xmpMM:OriginalDocumentID.+", "gim");
var result = str.match(regEx);
if (result != null)
{
return result;
}
}
File(ctpath)
.getFiles(function(v) {v.name.indexOf('_bustfront1') + 1 && open(v)})
var doc2 = app.activeDocument;
var fName = doc2.name;
var rawData2 = doc2.xmpMetadata.rawData;
//alert(rawData);
var id01 = find_original_document_ID(rawData2);
function find_original_document_ID(str)
{
var regEx = new RegExp(".+xmpMM:OriginalDocumentID.+", "gim");
var result = str.match(regEx);
if (result != null)
{
return result;
}
}
doc2.close();
// I stucked here, alert always shows even it true or false
if (idCT == id01) {}
else {alert (ctname + idCT + '\n' + '\n' + fName + id01)}
If by phyiscal id you mean OriginalDocumentID then yes It can be found with
app.activeDocument.xmpMetadata.rawDataThere are probably better ways to get the ID from the XML, but you get the idea.
It should just be a matter of comparing ID1 == ID2 after that.