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 ...
Copy link to clipboard
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
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.
activeDocument.path.fullName.split(/\/shop\//i).length - 1
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"
It works as expected:
unfortunately the error happens!
Does this fin work for you?
alert (activeDocument.path.fullName.match (/ \ / shop \ / (. +)? \ // i) )
As you can guess. What is your full name without regex match?
@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:
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.
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.
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.
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?
It seems to me it's not "he", but "she"
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.
@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.
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.
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: