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

Check if there is a folder with a specific name in the path.

Engaged ,
May 28, 2021 May 28, 2021

Copy link to clipboard

Copied

Hey guys!
How do I check if the active document is saved in a subfolder inside a folder called "SHOP", "shop" or "Shop"?
Here is the directory:
Y: /MATRIZ/28.05.2021/SHOP/subfolder/myfile ...
Thanks!

TOPICS
Actions and scripting

Views

3.7K

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 2 Correct answers

LEGEND , May 28, 2021 May 28, 2021

 

/^shop$/i.test(activeDocument.path.parent.name)

 

Votes

Translate

Translate
LEGEND , May 29, 2021 May 29, 2021
activeDocument.path.fullName.split(/\/shop\//i).length - 1

Votes

Translate

Translate
Adobe
LEGEND ,
May 28, 2021 May 28, 2021

Copy link to clipboard

Copied

 

/^shop$/i.test(activeDocument.path.parent.name)

 

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 ,
May 28, 2021 May 28, 2021

Copy link to clipboard

Copied

Hi @Kukurykus  thanks for the quick and effective response. It worked well, you are very nice.
Is there another way for the script to check everything from the "SHOP" folder in a path regardless of the number of subfolders according to the hierarchy? In other words: recognize that there is a folder called "Shop" on every path
Example:
SHOP/subfolder/other subfolder / ...... / myfile
Sorry for the delay in thanking you, I have faced problems when posting on this forum, msg of errors in the html.

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 ,
May 29, 2021 May 29, 2021

Copy link to clipboard

Copied

activeDocument.path.fullName.split(/\/shop\//i).length - 1

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 ,
May 29, 2021 May 29, 2021

Copy link to clipboard

Copied

Perfect! @Kukurykus  Thanks again for sharing your knowledge and answering my call.

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 ,
May 29, 2021 May 29, 2021

Copy link to clipboard

Copied

Interesting! I have long been looking for something like this.
@Kukurykus  if you allow me and if possible, how would it be possible to idenfy, show the subfolder name "on level 1" after the regex filtered folder "shop" in a path?.
...... / shop / that subfolder / subfolders / ...... /file.tiff
How to display the level 1 folder name: "this subfolder"
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
LEGEND ,
May 29, 2021 May 29, 2021

Copy link to clipboard

Copied

 

activeDocument.path.fullName.match(/\/shop\/(.+)?\//i)[1]

 

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 ,
May 29, 2021 May 29, 2021

Copy link to clipboard

Copied

alert(activeDocument.path.fullName.match(/\/shop\/(.+)?\//i)[1])

Captura de tela 2021-05-29 125341.jpg

 

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 ,
May 29, 2021 May 29, 2021

Copy link to clipboard

Copied

It works as expected:

'/d/shop/that subfolder/subfolders'.match(/\/shop\/(.+)?\//i)[1]

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 ,
May 29, 2021 May 29, 2021

Copy link to clipboard

Copied

unfortunately the error happens!
Does this fin work for you?
alert (activeDocument.path.fullName.match (/ \ / shop \ / (. +)? \ // i) [1])

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 ,
May 29, 2021 May 29, 2021

Copy link to clipboard

Copied

As you can guess. What is your full name without regex match?

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 ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

@Kukurykus  I don't know if you understand me, but come on!
In the print shop I work in, all image files are saved on a Server that contains a main folder called "Data", which contains a subfolder called "Matrix", which contains other subfolders named after the name of each client type: "Cliente_01" .
That said, it has this path:
C: /Servidor/Data/Matriz/Cliente/file.tiff

Once I have the document open, I just need the script to display only the name of the "Client" folder regardless of what name it is, as long as it is always the first folder after the "Matrix" folder in the respective path.
C: /Servidor/Data/Matriz/Cliente/file.tiff

Captura de tela 2021-05-30 144424.png
Once the script tells me the name of the "Customer", it will be added in a text layer as a caption in the lower right corner. That and I can do it well.
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
LEGEND ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

It has nothing to do with your previous request where you wanted name of folder contained in other folder you specified a name for. So yes - I do not understand what you exactly want.

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 ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

@Kukurykus sorry i was not clear, i just used the example of @Shulipa Bernad  posting, your solution had an error and then asked me this question: "What is your full name without regex correspondence"? showing my example.
But I am grateful for your willingness to help me.

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 ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

So why previously you used this example: /shop/that subfolder/subfolders/....../file.tiff

 

btw in the other post r-bin talked about you, not an original poster like I wrongly thought 😉

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 ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

alert(File.decode(activeDocument.path.name));

 

yes ?

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 ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

I'm sure he knows he can do it this way, so I even did not suggested it. The question is what his another request has to do with that he showed here with. I don't see connection, do you?

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 ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

It seems to me it's not "he", but "she"

🙂

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 ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

Not if we talk about an user 😉 To be honest I see how the first name ends, but in some countries it is a male name. Probably he's female, but that name in this case is for me like italian Andrea, not french Andrea. That's more 'indian', so it's why it fits to my suspictions.

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 ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

@Kukurykus  i think i understand the question
I believe you want to get the name of the first folder within the "Matrix" folder that would be the folder for a respective client "Client", C: /..../ Matrix / Client. If that's the case, I think @r-bin  has already found the answer but it doesn't work if there are more than 1 level inside it: C: /..../ Matrix / Client / impressionA or impressionB, it will always show the last level and the Client folder does not refer to it, unless there is a way to filter by levels since there is a defined path.

Type: show only the folder name referring to level 4 from C: / ... maybe with regular expressions.

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 ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

The r-bin answer is obvious, and I found it too according new request of smithcgl9043167. Because his first request differs from later expectations I let him say again what exactly he wants, since as you see the name of folder may be on different folders hierarchy level, but (s)he didn't say is that eventually any problem, whether first request used bad example.

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 ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

quote

Type: show only the folder name referring to level 4 from C: / ... maybe with regular expressions.


By @Shulipa Bernad
friend that would be exactly what i need, you explained it very well.

 

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 ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

alert( File.decode( activeDocument.path.fullName.split("/")[5] ) );

 

help: https://www.w3schools.com/jsref/jsref_split.asp

 

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 ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

Wow that's amazing! @r-bin  you are a true genius 👏👏👏. Thank you for that. My sincere thanks to @Kukurykus  and especially @Shulipa Bernad  for this wonderful topic. 

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 ,
May 31, 2021 May 31, 2021

Copy link to clipboard

Copied

LATEST

The code I shared originally did not work for you because you used it without subfolders between 'Cliente' and the file, so like that was in provided example. To make that works with/out subfolders you should use one of modified version of code I posted higher:

 

activeDocument.path.fullName.match(/\/Matrix\/(.+?)(\/|$)/i)[1]
decodeURI(activeDocument.path).match(/\/Matrix\/(.+?)(\/|$)/i)[1]
decodeURI(activeDocument.fullName).match(/\/Matrix\/(.+?)\//i)[1]

 

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