Only encode files within specific folders in a workfolder.

Questions and answers on how to get the most out of FFAStrans
Post Reply
Conniver
Posts: 36
Joined: Thu Jan 12, 2023 8:32 am

Only encode files within specific folders in a workfolder.

Post by Conniver »

If I'd want to only encode files within folders named "Media", is there a way to check for this?

I want to set "Monitor Folder" on a folder that contains several projects, but I don't want to make proxies of exported files and other files that is not
camera footage.
Within every Project folder in the Projects folder, there is a Media folder, witch contains all camera footage.

The path of the footage might look something like this
F:\Projects\Documentar01\Media\Day1\Card1\XDROOT\CLIP\

is it possible to only encode the files within the media folder for all projects in the Media folder?

Is it possible with the if exist dos command?

Code: Select all

%comspec% /C
"IF EXIST
"%Media%"
(EXIT /B 0)
ELSE
(EXIT /B 1)"
emcodem
Posts: 1749
Joined: Wed Sep 19, 2018 8:11 am

Re: Only encode files within specific folders in a workfolder.

Post by emcodem »

Hi,

sure, you got multiple options for that of course but an external batch does not really fit, most string operations in batches are not really easy to develop and maintain in general.

In a batch it can potentially look like (not tested)

Code: Select all

@setlocal enableextensions enabledelayedexpansion
@echo off
set str1=%s_source%
IF NOT x%str1:media=%==x%str1% (EXIT /B 0)
EXIT /B 1
endlocal
Another way might bi instead of batch just a single cmd that automatically exits positive or negative, e.g. findstr:

Code: Select all

echo "%s_source%" |findstr \media
My preffered variant would be conditional processor and functions. Also using the "dispel" checkbox, you can just delete jobs that were rejected completely from history and logging.

E.g. count function:
Conditional processor: $count("%s_source%","\media\")

Regext function would do as well but let's keep it simple here:D
emcodem, wrapping since 2009 you got the rhyme?
ThomasM
Site Admin
Posts: 231
Joined: Wed Feb 22, 2017 6:36 am

Re: Only encode files within specific folders in a workfolder.

Post by ThomasM »

Hi Conniver,

@emcodem is - as always - great with ideas. But I don´t know why he do not want to use regEx - he urged me to learn that, so... ;-)

maybe you can try a ConditionalNode:

Code: Select all

If [%s_source%] is Equal To (=), regex [(Media)]
conditional RegEx.png
conditional RegEx.png (8.2 KiB) Viewed 2992 times
cheers,
Thomas
emcodem
Posts: 1749
Joined: Wed Sep 19, 2018 8:11 am

Re: Only encode files within specific folders in a workfolder.

Post by emcodem »

Hehe, this case is just too simple and the user too new to qualify the extra complexity that regex adds :D
E.g. the one you posted @ThomasM

Code: Select all

(Media)
Would not really work because it would also match any filename or subfolder that contains the word "media". So we need the backslashes but as we are using regex, we need double backslashes...
Some other problems with regex: do we need a full match or just a part match? E.g. why did you add the parantheses for a group match? :D

A correct regex would probably look like:

Code: Select all

.*?\\Media\\.*|.*?\\media\\.*
..all depending on the user's exact needs of course :D

Also, if we later on need to add e.g. some path from some inbuilt variable, we would need to add the escaping to that as well, e.g.
%s_original_folder%\\Media\\.*
This would not work because original folder variable contains potentially characters that need regex escaping so we'd need to prepend a populate vars processor that applies the escaping to the variable before we use it for regex matching...
emcodem, wrapping since 2009 you got the rhyme?
Conniver
Posts: 36
Joined: Thu Jan 12, 2023 8:32 am

Re: Only encode files within specific folders in a workfolder.

Post by Conniver »

I have used the
Conditional processor: $count("%s_source%","\media\")
example from emcodem, and it worked just as I wanted. :)

I'm going to look into regEx aswell, I'm very interested in learning as much as I can about FFastrans.

Thanks!
ThomasM
Site Admin
Posts: 231
Joined: Wed Feb 22, 2017 6:36 am

Re: Only encode files within specific folders in a workfolder.

Post by ThomasM »

Hi all,
emcodem wrote: Thu Jan 26, 2023 5:32 pm Hehe, this case is just too simple and the user too new to qualify the extra complexity that regex adds :D
E.g. the one you posted @ThomasM

Code: Select all

(Media)
Would not really work because it would also match any filename or subfolder that contains the word "media". So we need the backslashes but as we are using regex, we need double backslashes...
yeah - true. And as always - great solution @emcodem!

I only checked this on the path given by Conniver:

Code: Select all

F:\Projects\Documentar01\Media\Day1\Card1\XDROOT\CLIP\
assuming that the filenames are that of a camera-style (e.g. A001C001_230126_F947.MOV) there will be no "word" or such.

so long...

Thomas
emcodem
Posts: 1749
Joined: Wed Sep 19, 2018 8:11 am

Re: Only encode files within specific folders in a workfolder.

Post by emcodem »

Conniver wrote: Thu Jan 26, 2023 9:46 pm I'm going to look into regEx aswell, I'm very interested in learning as much as I can about FFastrans.
That comes automatically when you need more fancy string matching stuff e.g. text or xml parsing :D
Btw, i forgot to mention Mr. steinars favourite method... in the conditional processor, using the "=" operator, one can also use wildcard "*", so afaik the condition can also look like
%s_source% = *\media*
emcodem, wrapping since 2009 you got the rhyme?
Conniver
Posts: 36
Joined: Thu Jan 12, 2023 8:32 am

Re: Only encode files within specific folders in a workfolder.

Post by Conniver »

I'm very interested in learning xml parsing. I really want to extract the locations of footage used in XML exported from editing, and use this data to download the footage from Dropbox through the API. But that is for a future project.
emcodem
Posts: 1749
Joined: Wed Sep 19, 2018 8:11 am

Re: Only encode files within specific folders in a workfolder.

Post by emcodem »

simple xml "parsing" with populate processor:
%s_my_variable% = $regext($read("__XMLFILEPATH__"),"<xmltag>(.+?)</xmltag>")

That should give you the value in <xmltag> into %s_my_variable% :D
But first of course you'll need to actually "find" the location and name of your xml in case the watchfolder does not specifically watch for xml files but some media file... Thats for another day :D
emcodem, wrapping since 2009 you got the rhyme?
Post Reply