Skip to main content
P__Raghu
Participant
December 30, 2016
Answered

File type based file movement into targeted folder

  • December 30, 2016
  • 3 replies
  • 1235 views

Hi,

I want move Raster format EPS (Photoshop created EPS) into separate folder,

and Vector format EPS (Illustrator/Acrobat created EPS) into separate folder.

via Bridge Scripting - File metadata based file movement into targeted folders...

Thanks in Advance.

This topic has been closed for replies.
Correct answer SuperMerlin

Very nice to see someone making an effort!

This example will create two folder and move all Photoshop EPS files into one folder and all others to the second folder.

All EPS files in the current folder are targeted.

#target bridge

if( BridgeTalk.appName == "bridge" ) { 

sortEPS = MenuElement.create("command", "Sort EPS Files", "at the end of Tools","eps");

}

sortEPS.onSelect = function () {

//deselect any selected files

app.document.deselectAll();

//select all eps files

var thumbs= app.document.getSelection("eps");

if(!thumbs.length) return; //No eps files

if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");

//create two folders to seperate eps files

var nonPSeps = new Folder(app.document.presentationPath+ '/Non Photoshop EPS');

if(!nonPSeps.exists) nonPSeps.create();

var PSeps = new Folder(app.document.presentationPath+ '/Photoshop EPS');

if(!PSeps.exists) PSeps.create();

//Iterate through all eps files

for(var a in thumbs){

//get metadata in read mode

var xmpf = new XMPFile(thumbs.spec.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ);

var xmp = xmpf.getXMP();

//Check if "CreatorTool"  field has data

if( xmp.doesPropertyExist(XMPConst.NS_XMP, "CreatorTool" ) ) {

//get CreatorTool information

var CreatorTool = xmp.getProperty(XMPConst.NS_XMP, "CreatorTool" ).toString();

if(CreatorTool.match("Photoshop")) {

//Photoshop eps file

    thumbs.moveTo(PSeps);

    }else{

//Non Photoshop eps file

        thumbs.moveTo(nonPSeps);

        }

}else{

//no xmp move to non Photoshop   

thumbs.moveTo(nonPSeps);

    }

}//end thumbs

};

P__Raghu
P__RaghuAuthor
Participant
January 5, 2017

Thank your for replay and code...

P__Raghu
P__RaghuAuthor
Participant
January 3, 2017

Here is some findings:

var thumbs = app.document.selections;

for(var a =0;a<thumbs.length;a++){

if(thumbs.type != "file") continue;

var t = new Thumbnail(thumbs.spec);      

var md = t.synchronousMetadata;

var Line ='';

Line = decodeURI(thumbs.name);

var creatorTool =  md.read("http://ns.adobe.com/xap/1.0/","xmp:CreatorTool");   

var displayPath = t.core.immediate.displayPath;

//var fileFormat = t.core.itemContent.fileFormat;

//var xResolution = t.core.quickMetadata.xResolution;

//var yResolution = t.core.quickMetadata.yResolution;

//var fileName = decodeURI(thumbs.name);

alert("File Location: "+displayPath + "\n" +"Creator Tool Name: "+creatorTool);

    }

How should i move files based on CreatorTool?

Stephen Marsh
Community Expert
Community Expert
January 3, 2017

Sorry, I can’t help there as I can’t script, which is why I use ExifTool. A single command line entry in ExifTool can often achieve what I am after, easier and faster than hoping that somebody will take pity on me and help with a script. That being said, sometimes I have to hope that somebody takes pity on me at the ExifTool forum and helps beyond the basics, however the community over there is really helpful so this is usually not a big deal. There are some knowledgeable contributors here, so with luck somebody can help with your Bridge script.

Stephen Marsh
Community Expert
Community Expert
January 1, 2017

I can do this via ExifTool, however I would need to rely on somebody to come up with the Bridge script for me, which is why I like ExifTool so much!

How would the Bridge script tell the difference between a vector EPS and a raster EPS? One possible method could be to base the metadata on the xmp:CreatorTool application such as Acrobat, Photoshop or Illustrator… However this would generate three different target folders, I am not sure if there is a single/common/shared metadata tag that could be used to only separate Photoshop EPS from Acrobat/Illustrator, some other logic or processing may be needed to clean this up based on different source tag values that may not be common.