Page 1 of 1
Only encode files within specific folders in a workfolder.
Posted: Tue Jan 24, 2023 11:32 pm
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)"
Re: Only encode files within specific folders in a workfolder.
Posted: Wed Jan 25, 2023 9:17 am
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:
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
Re: Only encode files within specific folders in a workfolder.
Posted: Thu Jan 26, 2023 4:38 pm
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 (8.2 KiB) Viewed 2994 times
cheers,
Thomas
Re: Only encode files within specific folders in a workfolder.
Posted: Thu Jan 26, 2023 5:32 pm
by emcodem
Hehe, this case is just too simple and the user too new to qualify the extra complexity that regex adds
E.g. the one you posted @ThomasM
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?
A correct regex would probably look like:
..all depending on the user's exact needs of course
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...
Re: Only encode files within specific folders in a workfolder.
Posted: Thu Jan 26, 2023 9:46 pm
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!
Re: Only encode files within specific folders in a workfolder.
Posted: Fri Jan 27, 2023 7:20 am
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
E.g. the one you posted @ThomasM
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
Re: Only encode files within specific folders in a workfolder.
Posted: Fri Jan 27, 2023 8:01 am
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
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*
Re: Only encode files within specific folders in a workfolder.
Posted: Fri Jan 27, 2023 9:32 am
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.
Re: Only encode files within specific folders in a workfolder.
Posted: Fri Jan 27, 2023 1:10 pm
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%
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