Locate File

Upload photoshop scripts, download photoshop scripts, discussion and support of photoshop scripts

Moderator: PS-Moderators

Locate File

Postby Mikeal.Sim » Wed Jul 14, 2010 8:00 am

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();
Mikeal.Sim
 
Posts: 46
Joined: Tue Jul 22, 2008 9:33 pm
Location: seattle

Re: Locate File

Postby Mike Hale » Wed Jul 14, 2010 2:07 pm

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.
Mike Hale
Site Admin
 
Posts: 4332
Joined: Fri Sep 30, 2005 10:52 pm
Location: USA

Re: Locate File

Postby Mikeal.Sim » Wed Jul 14, 2010 3:57 pm

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.");
};}
Mikeal.Sim
 
Posts: 46
Joined: Tue Jul 22, 2008 9:33 pm
Location: seattle


Return to Photoshop Scripts

Who is online

Users browsing this forum: No registered users and 1 guest