Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Convert Active Document File Path to Windows Format

Engaged ,
Dec 17, 2017 Dec 17, 2017

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?

TOPICS
Actions and scripting
2.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Dec 17, 2017 Dec 17, 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

Translate
Adobe
LEGEND ,
Dec 17, 2017 Dec 17, 2017

decodeURI(activeDocument.path)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 17, 2017 Dec 17, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 17, 2017 Dec 17, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 17, 2017 Dec 17, 2017

Yes, that was it, thank you so much.  Works perfectly.  No matter how hard I searched, I couldn't figure out what member function / variable was responsible for returning the correct file path.  Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 17, 2017 Dec 17, 2017

Searching is well is an art with pratice you can find what you need.  Often you find too many tings you do not want. Search engines vary.

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 03, 2020 Apr 03, 2020
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines