Skip to main content
Participating Frequently
May 29, 2007
Question

Problem using thumbnail moveTo() method

  • May 29, 2007
  • 4 replies
  • 633 views
(I would swear that I posted this message yesterday, but it doesn't show up so I am trying again.)

I am adding a context menu item for thumbnails to move allow me to move selected thumbnails to another location, creating the new location if necessary. The script is creating the new directory correctly but moveTo(newDirectory) is always failing. I presume I am doing something wrong, but don't know what it is. I would appreciate any guidance.

cntCommand.onSelect = function(m)
{
app.synchronousMode = true; // This doesn't help
$.writeln("onSelect entered");
var thumb = app.document.thumbnail;
var targetDir = CreateSubFolder(thumb, "Rejects");
$.writeln("Target directory is: " + targetDir);
var targetThumb = new Thumbnail (targetDir);
// Also tried moveTo(targetDir) with same failure
if (!thumb.moveTo (targetThumb)) {
$.writeln("moveTo failed");
}
};

function CreateSubFolder( doc, folderName ) {
$.writeln("CreateSubFolder entered");
var imgPath = doc.path
var dirName = imgPath + "/" + folderName

var targetDir = new Folder(dirName)
$.writeln("CreateSubFolder: " + dirName);
if (!targetDir.exists) {
targetDir.create();
}
return targetDir;
}
This topic has been closed for replies.

4 replies

Participating Frequently
May 30, 2007
David,

Great! Thank you for your help. This code is now doing what I want:

var selected = app.document.selections;
for( var i = 0; i < selected.length; ++i ) {
var image = selected;
image.moveTo(targetDir);
}

Now that I have this little piece working I can developing what I really need (a somewhat complicated variation on this theme).

Guy
dfranzen_camera_raw
Adobe Employee
Adobe Employee
May 30, 2007
Guy,

To get an array of all the Thumbnails selected in a window (err... a Document in the DOM) use: Document.selections.

Be sure to check out the documentation and example scripts in the Bridge CS3 SDK. There's a lots of great stuff in there.

-David
Participating Frequently
May 30, 2007
David,

Thank you. That points me in the right direction. I had thought thumb was the Thumbnail for the selected image. I guess it's the Thumbnail for the current folder instead?

My goal is to move all selected images to the new folder being created.

Is the onSelect() method called once for each selected image, or is it called just once and I have to iterate over the selected images? Is there an easy way to move all selected images to the new folder? If I have to iterate over the selected images, I'd appreciate seeing a sample of how to do that.

Thanks!

Guy
dfranzen_camera_raw
Adobe Employee
Adobe Employee
May 29, 2007
Guy,

Maybe I'm misreading your script, but it does not make sense to me.

You are calling:

thumb.moveTo(targetThumb);

When it appears that targetThumb is a sub-folder of thumb. When I tried to run the script, for example it tried to move "/Users/dfranzen/Documents" into "/Users/dfranzen/Documents/Rejects", and I would not expect that to work.

-David Franzen
Adobe Bridge Quality Engineering