Skip to main content
Known Participant
November 7, 2024
Answered

reveal in explorer js

  • November 7, 2024
  • 4 replies
  • 3783 views

Is it possible to use the "Reveal in Explorer" function using jsx? After using it, I want it to appear correctly in the image I am opening in Photoshop. Thank you, have a good day everyone

This topic has been closed for replies.
Correct answer r-bin

Maybe I understood what you want

 

var the_name = activeDocument.name;

var files = activeDocument.path.getFiles();

files.sort(sort_func);

function sort_func(a, b) 
    {
    // Sorting will be alphabetical. 
    // It may differ from the one set in the explorer, especially for names with numbers.
    // For exact matching of sorting, you need to write another sorting function. 
    // Google will help you. )

    if (a > b) return 1;
    else if (a < b) return -1;
    else return 0;
    }

// here you can close activeDocument
// activeDocument.close(SaveOptions.DONOTSAVECHANGES);


for (var i = 0; i < files.length; i++)
    {
    if (files[i].name.toLowerCase() == the_name.toLowerCase())
        {
        if (i != files.length-1) 
            {
            open(files[i+1]);
            break;
            }    
        }
    }

if (i == files.length) alert("it was the last file");

 

 

4 replies

Stephen Marsh
Community Expert
Community Expert
November 8, 2024

@trường_1768 

 

Rather than telling us what steps you think you would like to do, perhaps just describe the process, the actual task. There may be a different way to the same result.

 

Such as:

 

"From a single folder, I would like to batch automate combining two alphabetically sorting files into a layered PSD file".

 

https://community.adobe.com/t5/photoshop-ecosystem-discussions/script-to-automate-load-files-into-stack/m-p/13499068#U14928257

 

 

 

Known Participant
November 8, 2024

yes. thank you. maybe because of the language barrier so my explanation is a bit confusing. but everything is resolved, maybe it will help the work for the company I am working for. thank you again

Stephen Marsh
Community Expert
Community Expert
November 8, 2024

OK, please mark the replies that helped as a correct answer.

 

If you need further help, perhaps post in your native language and we can use translation software.

Known Participant
November 8, 2024

awesome genius minds, thats what i was looking for all along. but when i run the script i want it to open the image next to it in photoshop, can you help me with that?

Known Participant
November 8, 2024

sorry i am a foreigner so it may be difficult for you to understand. i want after running the script above to transfer to BR and i want to open the image next to the image when i run the script in PTS

r-binCorrect answer
Legend
November 8, 2024

Maybe I understood what you want

 

var the_name = activeDocument.name;

var files = activeDocument.path.getFiles();

files.sort(sort_func);

function sort_func(a, b) 
    {
    // Sorting will be alphabetical. 
    // It may differ from the one set in the explorer, especially for names with numbers.
    // For exact matching of sorting, you need to write another sorting function. 
    // Google will help you. )

    if (a > b) return 1;
    else if (a < b) return -1;
    else return 0;
    }

// here you can close activeDocument
// activeDocument.close(SaveOptions.DONOTSAVECHANGES);


for (var i = 0; i < files.length; i++)
    {
    if (files[i].name.toLowerCase() == the_name.toLowerCase())
        {
        if (i != files.length-1) 
            {
            open(files[i+1]);
            break;
            }    
        }
    }

if (i == files.length) alert("it was the last file");

 

 

Legend
November 7, 2024

 

for windows

var cmd = "explorer /select," + activeDocument.fullName.fsName;
system(cmd);

 

May not work with non-English names.

Known Participant
November 8, 2024

Thank you. This is a very great answer. Exactly what I need, thank you again. Wish you a good day

Stephen Marsh
Community Expert
Community Expert
November 7, 2024

@trường_1768 

 

Set a variable to the Folder object, and then you can use .execute() to open the folder in either Windows Explorer or the Finder on the Mac.

 

var theFolder = Folder(app.activeDocument.path);
theFolder.execute();

 

Or just skip the variable:

 

Folder(app.activeDocument.path).execute();

 

I don't know how to have the file selected in Explorer, that would probably take some extra scripting to call on local operating system commands.

 

It is possible when calling Adobe Bridge:

 

 

Known Participant
November 8, 2024

this is the answer i was looking for. But I still thank you for your help. Wish you a good day