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!
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?
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.
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(...
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…
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
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?
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
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");
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....
Copy link to clipboard
Copied
That might be possible by re-writing the .BridgeSort file as in the post below.
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.
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.
Copy link to clipboard
Copied
Ahhh, awesome! Going to test this afternoon. Thank you!
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!
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;
};
};
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!
Copy link to clipboard
Copied
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;
};
};