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

File type based file movement into targeted folder

Community Beginner ,
Dec 30, 2016 Dec 30, 2016

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.

TOPICS
Scripting
1.3K
Translate
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

correct answers 1 Correct answer

Guide , Jan 03, 2017 Jan 03, 2017

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.getSelecti

...
Translate
Community Expert ,
Jan 01, 2017 Jan 01, 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.

Translate
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 Beginner ,
Jan 02, 2017 Jan 02, 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?

Translate
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 ,
Jan 02, 2017 Jan 02, 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.

Translate
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
Guide ,
Jan 03, 2017 Jan 03, 2017

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

};

Translate
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 ,
Jan 03, 2017 Jan 03, 2017

Excellent work SuperMerlin! And a nice reminder that trying to help oneself may result in others offering more help than simply asking for help without trying! :]

Just curious, would you have chosen the XMP:CreatorTool too without my prior suggestion, or would you have used different metadata as a hook?

For the record, here is the ExifTool code, which would result in three folders titled Adobe Illustrator, Adobe Acrobat, Adobe Photoshop:

exiftool '-directory<${directory}/${PostScript:Creator;s#^(\S+\s\w+).*#$1#g}' '/Users/currentuser/Desktop/Input Directory' -ext .eps -r

This command will recursively scan all subfolders for EPS files within the top level parent “Input Directory” folder of the current logged in user. This command line code is from the Mac OS, on Windows OS simply change the single straight quote/foot mark ' to straight double quote/inch marks " with the correct platform specific path to the top level folder. Although ExifTool can use if/else logic, I have not yet worked out how to create only two folders so the result would be three if there were three different source programs that created the EPS files.

Translate
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
Guide ,
Jan 03, 2017 Jan 03, 2017

Hi Stephen, I always check the rawdata (File Info) to see what are the best fields to use.

I don't use eps files myself so I created a few in Photoshop and download a few others.

PS_Write.F, (ImageMagick), ps_write.f90, Adobe Illustrator CC (Windows)

ExifTool is still the Industry standard and is the best tool if you cant script yourself.

It's great that you are showing the ExifTool examples, it will help many people!

Translate
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 Beginner ,
Jan 05, 2017 Jan 05, 2017
LATEST

Thank your for replay and code...

Translate
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