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

Convert Active Document File Path to Windows Format

Engaged ,
Dec 17, 2017 Dec 17, 2017

Copy link to clipboard

Copied

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

Views

1.8K

Translate

Translate

Report

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

Votes

Translate

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

Copy link to clipboard

Copied

decodeURI(activeDocument.path)

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

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