Skip to main content
Known Participant
May 18, 2010
Answered

Batch of files manually sorted in Bridge - Can I run a PS Action in that manual order?

  • May 18, 2010
  • 2 replies
  • 5389 views

For some jobs my workflow ideally involves manually sorting the order of a batch of RAW files in Bridge (the RAW file names are as assigned by the camera) and then using a PS Action from Bridge to convert, save, and rename the batch of files. I want to end up with my image files sequentially numbered in the manually sorted order.

However, my PS Action automatically processes the files in ascending order of their RAW file names and therefore my manually assigned file order in Bridge is lost.

Is there a script (or other method) which will allow me to run a PS action from Bridge on a batch of files while keeping the manually sorted order for the purposes of the numbering sequence of the renamed output files?

My current workaround is to Batch Rename in Bridge a copied set of RAW files as an intermediate step to running my PS Action on the renamed RAW file copies. It's not a bad workaround but if there is an easier way, I would much appreciate knowing about it!

Geoff

This topic has been closed for replies.
Correct answer Paul Riggott

Thanks, Mark!

Geoff


Tis my fault alltogether! I have an extra reversal in the code Geoff.

Either remove Line 430 fileList=fileList.reverse(); or tick the reverse order, hopefully that should fix it.

2 replies

Paul Riggott
Inspiring
May 24, 2010

I have written a Photoshop script that proccesses selected Bridge files that might do what you want...

http://www.ps-scripts.com/bb/viewtopic.php?f=10&t=3383&sid=2a00fa49def7693787b1fa1dd7330da4

Muppet_Mark-QAl63s
Inspiring
May 24, 2010

Paul you could have said earlier and saved me some time… Bet it works a lot better too…

Paul Riggott
Inspiring
May 24, 2010

I have only just finished it Mark

Muppet_Mark-QAl63s
Inspiring
May 19, 2010

I just tried with a small test and if I use the document selectAll() method then get the selections array then the list is always returned in the order of the containing document/window… This was my test JavaScript snippet that I used to test with…

#target bridge with (app.document) {      if (sorts[0].type == 'user') {           if (selections.length == 0) {                selectAll();                var x = selections;                deselectAll();           } else {                var x = selections;           }           for (var i = 0; i < x.length; i++) {                $.writeln(x.name);           }      } else {           alert('This window is NOT a manual sort?')      } }

So I don't really see any reason why the files could NOT be processed utilizing this order…

Geoff.GAuthor
Known Participant
May 20, 2010

Thanks very much for your response, Mark.

I would love to learn how to write scripts at some point but unfortunately I am not able to spend the time climbing that particular learning curve at the moment. Would anyone give me an idea as to how much a script writer might charge to do something like this (assuming it is possible as you think it may be) and if so, where might I find someone?

Thanks,

Geoff

Muppet_Mark-QAl63s
Inspiring
May 22, 2010

Geoff, here is an example that works for me. When I test ran the sample script based on some stuff that I do the files are process in the order of the manual sort and only the files in my selection are processed folders etc are ignored… I have NO idea how much people charge for this sort of thing I only do it for the learning process. If you can let me know what the Photoshop process is and your OS I 'may' be able to help but I make NO promises as Im still very much the learner with this stuff…

You can give this a test if you like…

#target bridge with (app.document) {      if (sorts[0].type == 'user') {           if (selections.length == 0) {                selectAll();                var userSel = selections;                deselectAll();           } else {                var userSel = selections;           }           for (var i = 0; i < userSel.length; i++) {                if (userSel.type == 'file') psProcess(userSel.spec);           }      } else {            alert('This window is NOT a manual sort?')      } } function psProcess(filePath) {      var psScript = 'while (app.documents.length) app.activeDocument.close(SaveOptions.PROMPTTOSAVECHANGES);' + '\n';      psScript += 'var userDialogs = app.displayDialogs; \n';      psScript += 'var userRulerUnits = app.preferences.rulerUnits; \n';      psScript += 'app.diaplayDialogs = DialogModes.NO; \n';      psScript += 'app.preferences.rulerUnits = Units.PIXELS; \n';      psScript += 'app.bringToFront(); \n';      // Pass File Object as toSource      psScript += 'var thisFile = ' + filePath.toSource() + '; \n';      psScript += 'var docRef = app.open(thisFile); \n';      psScript += 'var baseName = docRef.name.slice(0, -4); \n';      // Edit the document      psScript += 'if (docRef.bitsPerChannel == BitsPerChannelType.SIXTEEN) docRef.bitsPerChannel = BitsPerChannelType.EIGHT; \n';      psScript += 'if (docRef.mode != DocumentMode.RGB) docRef.changeMode(ChangeMode.RGB); \n';      psScript += 'if (docRef.colorProfileName != "sRGB IEC61966-2.1") docRef.convertProfile("sRGB IEC61966-2.1", Intent.RELATIVECOLORIMETRIC); \n';      psScript += 'docRef.flatten(); \n';      // Call some functions      psScript += 'processChannels(docRef); \n';      psScript += 'processPaths(docRef); \n';      psScript += 'if (docRef.pathItems.length >= 1) processSelection(docRef, 0); \n';      psScript += 'fitImage(docRef, 880, 72); \n';           psScript += 'docRef.resizeCanvas(900, 900, AnchorPosition.MIDDLECENTER); \n';      // set up new file path to save document      psScript += 'var newFilePath = new File("~/Desktop/" + baseName + ".jpg"); \n';      psScript += 'saveFileasJPEG(newFilePath, 9); \n';      //      Close doc & put back prefs      psScript += 'app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); \n';      psScript += 'app.diaplayDialogs = userDialogs; \n';      psScript += 'app.preferences.rulerUnits = userRulerUnits; \n';           // Use eval & toSource for Photoshop functions      psScript += 'eval' + processChannels.toSource(); + '; \n';      psScript += 'eval' + processPaths.toSource(); + '; \n';      psScript += 'eval' + processSelection.toSource(); + '; \n';      psScript += 'eval' + fitImage.toSource(); + '; \n';      //psScript += 'eval' + imageArea.toSource(); + '; \n';      //psScript += 'eval' + saveFileasTIFF.toSource(); + '; \n';      psScript += 'eval' + saveFileasJPEG.toSource(); + '; \n';      // Send script to Photoshop      btMessaging('photoshop', psScript); } /****************************************** General Functions ******************************************/ function btMessaging(targetApp, script) {      var bt = new BridgeTalk();      bt.target = targetApp;      bt.body = script;      bt.send(); } function createFolder(folderPath) {      var thisFolder = new Folder(folderPath);      if (!thisFolder.exists) thisFolder.create(); } /****************************************** Photoshop Functions ******************************************/ function processChannels(docRef) {      for (var i = docRef.channels.length-1; i >= 0; i--) {           if (docRef.channels.kind == ChannelType.MASKEDAREA) {                docRef.channels.remove();                continue;           }           if (docRef.channels.kind == ChannelType.SELECTEDAREA) {                docRef.channels.remove();                continue;           }           if (docRef.channels.kind == ChannelType.SPOTCOLOR) {                docRef.channels.merge();           }      } } function processPaths(docRef) {      if (docRef.pathItems.length >= 2) {           for (var i = 0; i < docRef.pathItems.length; i++) {                if (docRef.pathItems.kind == PathKind.CLIPPINGPATH) {                     docRef.pathItems.makeClippingPath(0.5);                     docRef.pathItems.makeSelection(0, true, SelectionType.REPLACE);                     docRef.pathItems.deselect();                }           }      }   if (docRef.pathItems.length == 1) {           if      (docRef.pathItems[0].kind == PathKind.WORKPATH) docRef.pathItems[0].name = 'Clipping Path'           docRef.pathItems[0].makeClippingPath(0.5);           docRef.pathItems[0].makeSelection(0, true, SelectionType.REPLACE);           docRef.pathItems[0].deselect();      } } function processSelection(docRef, offSet) {      if (docRef.layers[0].isBackgroundLayer) docRef.layers[0].isBackgroundLayer = false;      docRef.selection.expand(offSet);      docRef.selection.invert();      docRef.activeLayer = docRef.layers[0];      docRef.selection.clear();      docRef.selection.deselect();      docRef.trim(TrimType.TRANSPARENT, true, true, true, true);      docRef.flatten(); } function fitImage(docRef, newSize, newRes) {   if (docRef.width >= docRef.height) {      docRef.resizeImage(newSize, undefined, newRes, ResampleMethod.BICUBICSMOOTHER);   }   else {      docRef.resizeImage(undefined, newSize, newRes, ResampleMethod.BICUBICSMOOTHER);   } } function imageArea(docRef, newArea, newRes) {   var originalArea = docRef.width * docRef.height;   if (originalArea > newArea) {      var newWidth = Math.sqrt(docRef.width * newArea / docRef.height);      var newHeight = (docRef.height * newWidth / docRef.width);      docRef.resizeImage(newWidth, newHeight, newRes, ResampleMethod.BICUBICSMOOTHER);   }   else {      docRef.resizeImage(undefined, undefined, newRes, ResampleMethod.NONE);   } } function bitmapOptions(res) {   bitOptions = new BitmapConversionOptions();      bitOptions.method = BitmapConversionType.HALFTHRESHOLD;      bitOptions.resolution = res;      bitOptions.shape = BitmapHalfToneType.SQUARE;      return bitOptions; } /****************************************** Photoshop Save As Functions ******************************************/ function saveFileasTIFF(saveFile, aC, iC, la, sC, tr) {      tiffSaveOptions = new TiffSaveOptions();      tiffSaveOptions.alphaChannels = aC;      tiffSaveOptions.byteOrder = ByteOrder.MACOS;      tiffSaveOptions.embedColorProfile = true;      tiffSaveOptions.imageCompression = iC;      tiffSaveOptions.layers = la;      tiffSaveOptions.spotColors = sC;      tiffSaveOptions.transparency = tr;      activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE); } function saveFileasJPEG(saveFile, qL) {      jpgSaveOptions = new JPEGSaveOptions();      jpgSaveOptions.embedColorProfile = true;      jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;      jpgSaveOptions.matte = MatteType.NONE;      jpgSaveOptions.quality = qL;      activeDocument.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE); }