Quantcast
Channel: Adobe Community: Message List - Photoshop Scripting
Viewing all articles
Browse latest Browse all 27456

Re: How to open an image in the same folder as a script (relative path)

$
0
0

I don't know javascript I just can hack others code.

 

// Find the location where this script resides

function findScript() {

  var where = "";

  try {

  FORCEERROR = FORCERRROR;

  }

  catch(err) {

  // alert(err.fileName);

  // alert(File(err.fileName).exists);

  where = File(err.fileName);

  }

  return where;

}

var Name = decodeURI(new File(findScript())).replace(/\.[^\.]+$/, ''); // strip the extension off);

var scriptPath = "";

while (Name.indexOf("/") != -1 ) {

         scriptPath= scriptPath + Name.substr(0, Name.indexOf("/") + 1);

         Name = Name.substr(Name.indexOf("/") + 1 ,);

         }

 

 

alert("Script Path = '" + scriptPath  +"'\rScript Name = '" + Name + "'");


Viewing all articles
Browse latest Browse all 27456

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>