Skip to main content
johnt53984649
Inspiring
December 17, 2017
Answered

Convert Active Document File Path to Windows Format

  • December 17, 2017
  • 2 replies
  • 2386 views

Observe the following lines of code:

#target Photoshop

var joy = app.activeDocument.path;

alert(joy);

Test this when you have some file open in Photoshop.  For example, it outputs something that looks like this:

/d/5)%20Projects/My%20Projects

but I need it to look like this:

D:\5) Projects\My Project

Now, let me make this clear; I need it in EXACTLY the format that I showed immediately above.  I'm working on a Windows machine, and I need to return this filepath in the Windows format for my HTML panel so that the user has easy access to it.  I need it to be just a standard string that includes the spaces and doesn't add in those extra percent signs and twenties.  Unfortunately, I have no idea how to do this.

So the real question here is; how can I obtain the active document's file path in the typical Windows format?

This topic has been closed for replies.
Correct answer Kukurykus

Current string of what ?! Decoding changes object, that path of active document becomes a string. You say you want to change object into string before you decode it? It gives you the same result. I completetly don't understand it Perhaps you want to check is activeDocument an active one from all others they can be opened, or maybe your document is not saved yet so there's no any location bound to? Ah I'm sorry I just read a title of your post again, so:

activeDocument.path.fsName

2 replies

Known Participant
April 3, 2020

What is the c++ equivalent of app.activeDocument.path

Kukurykus
Brainiac
December 18, 2017

decodeURI(activeDocument.path)

johnt53984649
Inspiring
December 18, 2017

This almost works, and I think it would, except I'm not sure that the app.activeDocument.path is an actual string.  So when I try it, it just completely fails.  So I think that I need to figure out how to convert app.activeDocument.path into a string first, but I haven't been able to find a way to do this.

Kukurykus
KukurykusCorrect answer
Brainiac
December 18, 2017

Current string of what ?! Decoding changes object, that path of active document becomes a string. You say you want to change object into string before you decode it? It gives you the same result. I completetly don't understand it Perhaps you want to check is activeDocument an active one from all others they can be opened, or maybe your document is not saved yet so there's no any location bound to? Ah I'm sorry I just read a title of your post again, so:

activeDocument.path.fsName