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

Sort jpgs via file list?

New Here ,
Jun 11, 2011 Jun 11, 2011

Copy link to clipboard

Copied

Would is be possible to write a custom manual bridge sort file (hidden file)?

The  idea would be able take a list of jpegs in a specific order and get  Bridge to to sort them according to the order on the list via preserved filename metadata.  Say an ordered list of images for an animated sequence?

Any advice and or a script would be great!

Thanks!

TOPICS
Scripting

Views

2.2K

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
Guru ,
Jun 13, 2011 Jun 13, 2011

Copy link to clipboard

Copied

I have not tried this but a brief look at the guide suggests that you can create your own 'SortCriterion object' this should allow for you to sort based on an xmp metadata field is this where your sort info is?

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
New Here ,
Jun 13, 2011 Jun 13, 2011

Copy link to clipboard

Copied

Could be a step in the right direction.  It would certainly connect the dots between the file list and the preserved filename in metadata, but finding the right jpegs isn't really the time suck on these tasks.  It's really getting them in the right order per a text file listing that order that takes so much time manually.

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
Valorous Hero ,
Jun 14, 2011 Jun 14, 2011

Copy link to clipboard

Copied

If the preserved filenames are in the order you want, you could copy the selected files to another folder and rename then back to the preserved filename IE:


var toFind = new Array();
var txtFile = File.openDialog("Please select the text file","*.txt");
txtFile.open('r');
while (newLine = txtFile.readln()) {
     if (newLine.length < 2) continue;
toFind.push(newLine.replace(/^[\s]+|[\s]+$/g, ''));
}
txtFile.close();
var Thumbs = app.document.visibleThumbnails; 
var fileList =[];
for(var a in Thumbs){
var t = new Thumbnail(Thumbs);
var md = t.synchronousMetadata
md.namespace = "
http://ns.adobe.com/xap/1.0/mm/"
var PreservedFileName = md.PreservedFileName;
fileList.push([[Thumbs.spec],[PreservedFileName]]);
}
var thisFolder = app.document.presentationPath;
var outFolder = Folder(...









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
Guru ,
Jun 14, 2011 Jun 14, 2011

Copy link to clipboard

Copied

Paul, can you see what's wrong with what I tried? I've had this syntax about 20ish ways now and although I get a custom sort it's NOT what I was hoping for… Still just works off the file name… Hum I'll be shot if I can work out why… Thought this would have been the easy route but not for me… That smells familiar…

#target bridge app.bringToFront(); var pfnSort = new SortCriterion('By Preserved Name', 'http://ns.adobe.com/xap/1.0/mm/', 'PreservedFileName'); var mySortObj = new Object(); //mySortObj.type = 'string'; mySortObj.name = 'By Preserved Name'; mySortObj.reverse = true; var mySortsArray = new Array(); mySortsArray.push(mySortObj); app.document.sorts = mySortsArray;

It's for the most part just c&p from the guide…

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 ,
Jun 14, 2011 Jun 14, 2011

Copy link to clipboard

Copied

As far as I can tell, the whole second half of the ref doc only works on custom nodes.

If you discover otherwise, I'd love to hear about it!!!

Harbs

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
Valorous Hero ,
Jun 14, 2011 Jun 14, 2011

Copy link to clipboard

Copied

Like Harbs I would love to get something like this working, any one from Adobe here that could help us poor souls?

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
Guru ,
Jun 14, 2011 Jun 14, 2011

Copy link to clipboard

Copied

So it's NOT just me whacking my head against a desk…? My first presumption is always me being dumb when things don't work as I would expect… I could not get the displayed name nor nothing to work yet it does sort… I don't think you can re-index the thumbs either…

Harbs… I see what I did now… Why do they put links from the 'DOM Object Reference' to the 'Advanced Developers' section… I ain't one of those and flew straight past 101 the intro… tut tut… Oh well only half the stuff to read now

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
Valorous Hero ,
Jun 14, 2011 Jun 14, 2011

Copy link to clipboard

Copied

This might show a bit of insight as the SortCriterion is not been added.

#target bridge
app.bringToFront();
var dsc = app.defaultSortCriteria;
alert("Sort functions = " + app.defaultSortCriteria.length);
var pfnSort = new SortCriterion('By Preserved Name', 'http://ns.adobe.com/xap/1.0/mm/', 'PreservedFileName');
alert("Sort functions = " + app.defaultSortCriteria.length);
alert(app.defaultSortCriteria.length +" note pfnSort has not been added");
var pfnSort = new SortCriterion('By Preserved Name', 'http://ns.adobe.com/xap/1.0/mm/', 'PreservedFileName');
dsc.push(pfnSort);
alert(app.defaultSortCriteria.length +" note pfnSort has not been added");
alert(dsc.length +" note pfnSort has been added to the copy");

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
New Here ,
Feb 22, 2014 Feb 22, 2014

Copy link to clipboard

Copied

Did you ever find a script for doing this? My job would be so much easier if bridge could sort based on a cut list/test list....

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
Enthusiast ,
Feb 23, 2014 Feb 23, 2014

Copy link to clipboard

Copied

That might be possible by re-writing the .BridgeSort file as in the post below.

http://forums.adobe.com/thread/1078601?tstart=0

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
New Here ,
Feb 24, 2014 Feb 24, 2014

Copy link to clipboard

Copied

Hmmmm... as far as I can tell, that script is still sorting by attributes, not a list? I would need to sort the files by name in a seemingly random order that exists in simple list format.

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
Enthusiast ,
Feb 24, 2014 Feb 24, 2014

Copy link to clipboard

Copied

Yup, that is exactly what a manual sort is. So building the .BridgeSort fiile will organize the files as per your list.

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
New Here ,
Feb 24, 2014 Feb 24, 2014

Copy link to clipboard

Copied

Ahhh, awesome! Going to test this afternoon.  Thank you!

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
New Here ,
Feb 24, 2014 Feb 24, 2014

Copy link to clipboard

Copied

Phillip that you for suggesting this and answering my questions!  Apoolgies for having more, I am a total novice with scripts.   I don't see where this script references an exsiting/external file list or what the perameters of that list need to be.  I can see how might want to manually alter the .bridgesort list match my list and then have bridge sort to that order, but I don't see where/how the .bridgesort list builds based on a txt list.  Sorry if it's blantaly obvious and I'm missing it.  I'm a total newbie with this stuff... Thanks!

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
Enthusiast ,
Feb 25, 2014 Feb 25, 2014

Copy link to clipboard

Copied

Hope this will help you, this code expects you to have a TEXT file with a list of filenaames that willl be used to sort the selected folder.

N.B. The text file MUST have the names of the files in SAME case as on disk.

Example: mypicture.jpg (in the text file ) is not the same as MyPicture.jpg on the disc. They must be the same!

#target bridge

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

var sortWithTextFile = new MenuElement( "command","Sort on TXT file", "at the end of Tools" , "txtsort" );

}

sortWithTextFile.onSelect = function () {

var txtFile = File.openDialog("Please select TEXT file.","TXT File:*.txt");

if(txtFile == null) return;

var fileNames = new Array();

txtFile.open('r');

while(!txtFile.eof){

var line = txtFile.readln();

if(line.length <4) continue;

fileNames.push(line.toString().replace(/^[\s]+|[\s]+$/g, ''));

}

txtFile.close();

var fileSort = new File(app.document.presentationPath +"/.BridgeSort");

var fileNames2 = new Array();

if(fileSort.exists) fileSort.remove();

var fileList=[];

for(var f in fileNames){

var tmpFile = File(app.document.presentationPath + "/" + fileNames.toString());  

if(!tmpFile.exists) continue; //Ignore files that do not exist, better to create an error file.

fD = File(tmpFile).created;

var FileDate = fD.getFullYear() + (zeroPad(fD.getMonth() +1,2).toString());

FileDate += (zeroPad(fD.getDate(),2).toString()) +  (zeroPad(fD.getHours(),2).toString());

FileDate += (zeroPad(fD.getMinutes(),2).toString()) + (zeroPad(fD.getSeconds(),2).toString());

fileList.push([[decodeURI(tmpFile.name)],[FileDate]]);

}

app.document.sorts = [{ type:"string",name:"name", reverse:false }];

fileSort.open("w", "TEXT", "????");

fileSort.lineFeed="Unix";

fileSort.encoding = "UTF-8";

fileSort.writeln("<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>");

fileSort.writeln("<dirinfo>");

fileSort.writeln("<files>");

for(var t in fileList){

    fileSort.writeln("<item key='" +fileList[0].toString().replace(/&/,"&") +fileList[1].toString() +"' />");

    }

fileSort.writeln("</files>");

fileSort.writeln("</dirinfo>");

fileSort.close();

fileSort.hidden=true;

app.document.chooseMenuItem("mondo/command/new");

app.documents[0].close();

app.document.sorts = [{ name:"user",type:"date", reverse:false }];

function zeroPad(n, s) {

   n = n.toString();

   while (n.length < s)  n = '0' + n;

   return n;

};

};

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
New Here ,
Feb 25, 2014 Feb 25, 2014

Copy link to clipboard

Copied

WOW! You've done it! This works like a charm.  I can't even begin to tell you how helpful this is.  Thank you, thank you, thank you! Thank you times a million!

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
Enthusiast ,
Feb 25, 2014 Feb 25, 2014

Copy link to clipboard

Copied

LATEST

Great, here is a modified version that will correct any case sensitive problems with the text file names (lines 28 and 29).

#target bridge

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

var sortWithTextFile = new MenuElement( "command","Sort on TXT file", "at the end of Tools" , "txtsort" );

}

sortWithTextFile.onSelect = function () {

var txtFile = File.openDialog("Please select TEXT file.","TXT File:*.txt");

if(txtFile == null) return;

var fileNames = new Array();

txtFile.open('r');

while(!txtFile.eof){

var line = txtFile.readln();

if(line.length <4) continue;

fileNames.push(line.toString().replace(/^[\s]+|[\s]+$/g, ''));

}

txtFile.close();

var fileSort = new File(app.document.presentationPath +"/.BridgeSort");

var fileNames2 = new Array();

if(fileSort.exists) fileSort.remove();

var fileList=[];

for(var f in fileNames){

var tmpFile = File(app.document.presentationPath + "/" + fileNames.toString());  

if(!tmpFile.exists) continue; //Ignore files that do not exist, better to create an error file.

fD = File(tmpFile).created;

var FileDate = fD.getFullYear() + (zeroPad(fD.getMonth() +1,2).toString());

FileDate += (zeroPad(fD.getDate(),2).toString()) +  (zeroPad(fD.getHours(),2).toString());

FileDate += (zeroPad(fD.getMinutes(),2).toString()) + (zeroPad(fD.getSeconds(),2).toString());

//get and use the correct filename as on hdd

var  t = new Thumbnail(tmpFile);

fileList.push([[decodeURI(t.spec.name)],[FileDate]]);

}

app.document.sorts = [{ type:"string",name:"name", reverse:false }];

fileSort.open("w", "TEXT", "????");

fileSort.lineFeed="Unix";

fileSort.encoding = "UTF-8";

fileSort.writeln("<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>");

fileSort.writeln("<dirinfo>");

fileSort.writeln("<files>");

for(var t in fileList){

    fileSort.writeln("<item key='" +fileList[0].toString().replace(/&/,"&") +fileList[1].toString() +"' />");

    }

fileSort.writeln("</files>");

fileSort.writeln("</dirinfo>");

fileSort.close();

fileSort.hidden=true;

app.document.chooseMenuItem("mondo/command/new");

app.documents[0].close();

app.document.sorts = [{ name:"user",type:"date", reverse:false }];

function zeroPad(n, s) {

   n = n.toString();

   while (n.length < s)  n = '0' + n;

   return n;

};

};

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