Verify first characthers folder name

Questions and answers on how to get the most out of FFAStrans
Post Reply
andrezagato
Posts: 43
Joined: Tue Jun 09, 2020 4:07 pm

Verify first characthers folder name

Post by andrezagato »

Hello,
I want to rename my output files using the folder name. But sometimes the right folder name is %s_original_path~2% or sometimes is %s_original_path~3%.
I would like to create some sort of verification that checks if the folder name starts with DXX_ (xx is numbers, ex: D01_, D10_, D11_, D25_).
I've loooked around for a solution, I got as far as $left, or $trim functions. But since the numbers vary, I can't figure how to do that.

I was thinking of conditionals if %s_original_path~2% = DXX_ then populate variable "%s_original_path~2%" = "s_right_folder_name" , then do the same for %s_original_path~3% and so forth.
Hope that made sense. Thanks in advance.
momocampo
Posts: 592
Joined: Thu Jun 08, 2017 12:36 pm
Location: France-Paris

Re: Verify first characthers folder name

Post by momocampo »

Hello Andrezagato,
If you know that your folder name always begins by "DXX_", it is really easy to extract only the number between "D" and "_".
You just have to populate the "%s_original_path%" and use Regex function :
s_right_folder_name" --> $regext("%s_original_path%","D(\d\d)_")
You will get the number in your folder name. Then, you can easily use this number at the end of your workflow inside the delivery node :
output.jpg
output.jpg (40.51 KiB) Viewed 4100 times
Feel free to tick "drop original name" if you only want the folder name instead of file name.

;)
andrezagato
Posts: 43
Joined: Tue Jun 09, 2020 4:07 pm

Re: Verify first characthers folder name

Post by andrezagato »

Hello Momocampo, thanks for the response.

I fell like this is part of what I have in mind. The issue is that the folder name contains more information.
The path is sometimes like this: D23_0624\SONY\D23_0624_PROVA_LABIRINTO_CAM_0201\CLIP\FILES.MXF
and sometimes like this: D32_0703\SONY\D32_0703_CAM2_PROVA\FILES.MXF

I've highlighted the folder name that I want to include as a variable to the output prefix. The problem is that sometimes it is 2 levels up, sometimes 1 level up. So what I was looking for is to do some validation to check the name.
So the logic in my head would be something like this:
Check if %s_original_path~1% starts with DXX_XXXX // all the X are numbers), if YES, set %s_original_path~1% to %new_folder_name_variable% OR
Check if %s_original_path~2% starts with DXX_XXXX // all the X are numbers), if YES, set %s_original_path~1% to %new_folder_name_variable%

With your solution I can extract that first 7 letters, but I can't figure out how to add the rest of the folder name, since the lenght varies.

Thanks again.
andrezagato
Posts: 43
Joined: Tue Jun 09, 2020 4:07 pm

Re: Verify first characthers folder name

Post by andrezagato »

Hello Momocampo, after your suggestion, I tried somethings and apparently got it working. Not sure if I'm missing out on something, but from my tests, it worked.

I'll attach here for you to check out if you can.

Thanks again!
Attachments
FOLDER NAME TESTS.json
(11.14 KiB) Downloaded 149 times
momocampo
Posts: 592
Joined: Thu Jun 08, 2017 12:36 pm
Location: France-Paris

Re: Verify first characthers folder name

Post by momocampo »

Yo Andrezagato,
Ok so I begin to see what you want, thanks for all these informations.
I think there is something simpler than your workflow. Using $left or $right function is not very reliable when there are variables strings and it seems it will be your case.
So if you are sure that your "good folder name" will be either path~1 or path~2, maybe we can use conditional node as you said :
"Check if %s_original_path~1% starts with DXX_XXXX // all the X are numbers), if YES, set %s_original_path~1% to %new_folder_name_variable% OR
Check if %s_original_path~2% starts with DXX_XXXX // all the X are numbers), if YES, set %s_original_path~1% to %new_folder_name_variable%"

I'm going to create and give you a workflow. Stay tuned ;)
cheers.
andrezagato
Posts: 43
Joined: Tue Jun 09, 2020 4:07 pm

Re: Verify first characthers folder name

Post by andrezagato »

Hey momocampo,

I was running my workflow yesterday and saw that the "good folder" can be sometimes path~3 or even path~4. This project was poorly managed at the recording site.
I'm looking forward for the workflow, I always learn a lot from them.

Thanks.
momocampo
Posts: 592
Joined: Thu Jun 08, 2017 12:36 pm
Location: France-Paris

Re: Verify first characthers folder name

Post by momocampo »

Hello andrezagato,
ok easy, we will find a solution. The problem is that you have several folder name that beginning by DXX_....So not easy to keep the good one.
But, maybe we can assume that your good folder always begins like that : "D_XX_" AND this good folder is always between "\" so you can try that :
populate node just after the monitor node and :

Code: Select all

s_right_folder_name" --> $regext("%s_original_path%","\\(D\d\d_.+?)\\")
In that way, only the folder name beginning by "D<number><number>_" inside a path (\.....\) will be kept in the variable.
It should be ok if you don't have any other folder name like this kind of.

Let me know if it is ok !
Cheers.
Benjamin
andrezagato
Posts: 43
Joined: Tue Jun 09, 2020 4:07 pm

Re: Verify first characthers folder name

Post by andrezagato »

Thanks momocampo! That is awesome. I've already tried and started using!
momocampo
Posts: 592
Joined: Thu Jun 08, 2017 12:36 pm
Location: France-Paris

Re: Verify first characthers folder name

Post by momocampo »

OK happy to hear.
If you have another issue, feel free to ask ;)
Cheers.
B.
Post Reply