How can I get the PWD for the Content pane?

General Discussion of Scripting for Adobe Bridge

Moderators: Tom, Kukurykus

miked

How can I get the PWD for the Content pane?

Post by miked »

I have a bridge script that is going to verify the existence of image files in the folder currently active in Bridge.

I have the file name root, and I need to ensure that a copy of the file name root exists as a JPG, a PSD or a TIF.

What I need is a way to get the path to the currently active folder in Bridge, such that my code will search in the right spot. So far I have this:
Code: Select allfunction fileExists(fileRoot) {
    var fileTypes = ["jpg","psd","tif"];
    var i;
    var f;
    var testName;
    for (i=0; i<fileTypes.length; i++) {
        testName = fileRoot + "." + fileTypes;
        alert("Checking for " + testName);
        var f = new File(testName);
        if (f.exists) {
            alert ("Found " + testName);
            return testName;
        }
    }
    alert("File not found!");   
    return false;
}

Clearly, I need to add a path, but I don't know how to get it. What I do know, though, is that the path should be the currently open folder in the Bridge content window.

How can I get it?

...Mike[/code]
miked

How can I get the PWD for the Content pane?

Post by miked »

I also need to be able to test for the file existence in a case-insensitive way, but only with the extension. ANy way to do that?

...Mike
Paul MR

How can I get the PWD for the Content pane?

Post by Paul MR »

A bit late but this should get you the current folder path/name.

Code: Select allalert(app.document.presentationPath);
xbytor

How can I get the PWD for the Content pane?

Post by xbytor »

miked wrote:I also need to be able to test for the file existence in a case-insensitive way, but only with the extension. ANy way to do that?

If the OS doesn't automagically do that for you (XP does, I believe), you will need to Folder.getFiles() to get the list of the files in that folder then compare the file names against the name in question, all in lowercase.

-X