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

How to summarize the path of a folder in the dialog box

Engaged ,
Sep 14, 2018 Sep 14, 2018

Copy link to clipboard

Copied

Hello everyone!

I remember I already saw this in some script but I can not remember which one.

I have in the dialog box with a static text that represents the path of a directory but it does not show its end once it exceeds the space limit.

Does anyone have any knowledge about this, and can you share? Thank you

Sample:

#target Photoshop

var dlg=new Window("dialog","My Dialog",[0,0,345,80]);   

var  btn_inputFolder = dlg.add("button",  {x:25, y:25, width:80,height:25} ,"Select Folder");   

var txt_Path = dlg.add("statictext",  {x:115, y:28, width:250,height:25} ,"C:/Users/MyComputer/folder02/Pictures",{multiline:true});

btn_inputFolder.onClick  = function() {

var inputFolder = Folder.selectDialog("Select a folder");

if(inputFolder !=null){txt_Path.text = inputFolder.fsName};

dlg.center();

dlg.show();

TOPICS
Actions and scripting

Views

1.1K

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

Community Expert , Sep 14, 2018 Sep 14, 2018

Hi mauricior6328708​,

cool - good finding. It seems to work now (in newer versions)

var txt_Path = dlg.add("statictext",  {x:115, y:28, width:200,height:25} ,"C:/Users/MyComputer/folder02/Pictures",{ truncate:'middle' }); 

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 14, 2018 Sep 14, 2018

Copy link to clipboard

Copied

Hi smithcgl9043167​

IMHO truncate() does not work in Adobe Extendscript.

Here is a possible solution:

jquery - How to truncate a string (containg a path) without touching the filename? - Stack Overflow

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 ,
Sep 14, 2018 Sep 14, 2018

Copy link to clipboard

Copied

Hi smithcgl9043167 what you want to add may be possible !.

Here's something that might help you:

if you notice this there is in the Image Provcessor.jsx script

Screenshot_1.jpg

I do not understand javascript and maybe someone can do it for you. Good luck

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 ,
Sep 14, 2018 Sep 14, 2018

Copy link to clipboard

Copied

Hi mauricior6328708​,

cool - good finding. It seems to work now (in newer versions)

var txt_Path = dlg.add("statictext",  {x:115, y:28, width:200,height:25} ,"C:/Users/MyComputer/folder02/Pictures",{ truncate:'middle' }); 

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 ,
Sep 14, 2018 Sep 14, 2018

Copy link to clipboard

Copied

pixxxel schubser you went very well! That was a perfect fit.

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
People's Champ ,
Sep 14, 2018 Sep 14, 2018

Copy link to clipboard

Copied

can also do this )

if(inputFolder !=null){txt_Path.helpTip=txt_Path.text=inputFolder.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
Community Expert ,
Sep 14, 2018 Sep 14, 2018

Copy link to clipboard

Copied

Hi r-bin​,

yes.

But I think he want see only

C:/Folder/v…rylongPath/Subfolder

instead of

C:/Folder/veryveryveryverylongPath/veryveryveryverylongPath/Subfolder

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
People's Champ ,
Sep 14, 2018 Sep 14, 2018

Copy link to clipboard

Copied

This pops up when you point the mouse at the text.

And what to do if the last folder is S1234567890uuuuuuuuuuuuuuuuuuuuuuuuuBBBBBBBBBBBBolder ?

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 ,
Sep 14, 2018 Sep 14, 2018

Copy link to clipboard

Copied

truncate.PNG

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
People's Champ ,
Sep 14, 2018 Sep 14, 2018

Copy link to clipboard

Copied

Untitled-1.png

:))

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 ,
Sep 14, 2018 Sep 14, 2018

Copy link to clipboard

Copied

LATEST

Screenshot_1.jpg

Perfect! It works divinely well.

mauricior6328708 Thanks for the tip fundamentel

pixxxel schubser Thanks for the solution

r-bin thanks for adding a tooltip to this function!

Thank you all!

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