Locate File

Upload Photoshop Scripts, download Photoshop Scripts, Discussion and Support of Photoshop Scripts

Moderators: Tom, Kukurykus

Mikeal.Sim

Locate File

Post by Mikeal.Sim »

This finds the location of the open file, and opens an explorer window with the file selected.
This is similar to "Revile in Explorer" common in other programs.

Code: Select all#target photoshop
app.bringToFront();
/*
<javascriptresource>
<name>Locate File</name>
<about>Will Open file location</about>
<menu>filter</menu>
<enableinfo>true</enableinfo>
</javascriptresource>
*/
var bat = new File(Folder.temp + "/locatefile.bat")
 bat.open("w");
 bat.writeln("@explorer.exe /select,"+app.activeDocument.fullName.fsName);
 bat.close();
 bat.execute();
Mike Hale

Locate File

Post by Mike Hale »

It would be nice to come up with an enableinfo expression to test if the doc has a file but I can not come up with one. I would at least put the script in a try/catch so it doesn't throw an error if the doc has never been saved.
Mikeal.Sim

Locate File

Post by Mikeal.Sim »

good point.

Code: Select all#target photoshop
app.bringToFront();
/*
<javascriptresource>
<name>Locate File</name>
<about>Will Open file location</about>
<menu>filter</menu>
<enableinfo>true</enableinfo>
</javascriptresource>
*/

try{
var test= app.activeDocument.fullName.displayName;
}catch(e){
   alert("Error, File Not Saved.");
};

if (test){
try{
var bat = new File(Folder.temp + "/locatefile.bat")
 bat.open("w");
 bat.writeln("@explorer.exe /select,"+app.activeDocument.fullName.fsName);
 bat.close();
 bat.execute();
}catch(e){
alert("Error, Can Not Open.");
};}