Page 1 of 1

Repeating loop if file name contains string [SOLVED]

Posted: 09 Aug 2021 02:23
by AlphaInc.
Hello everybody,

With the help of this forum I created a little batch script which runs a command for every mkv-file inside a specific folder and creates an output-file for every file while also increasing a counter. Now I want to expand on this that the script only runs for mkvs in that folder that contain the string *example*. How do you do this:

Code: Select all

@echo on 
setlocal DisableDelayedExpansion

set /A fileCounter=0
	for %%A in (*.mkv) do (
		for /r %%A in (*example*) do ( 			<-- This is where I ran into problems.
			set /A "fileCounter+=1"
			set "name=%%A"
			setlocal EnableDelayedExpansion
			C:\System\Mediainfo\MediaInfo.exe --Inform=file://C:\System\Mediainfo\alphaVideo_template.txt "%%A" >> Output_!fileCounter!.txt
			endlocal
		)
	)
	
exit

Re: Repeating loop if file name contains string

Posted: 09 Aug 2021 02:54
by aGerman

Code: Select all

for %%A in ("*example*.mkv") do (
Maybe?

Steffen

Re: Repeating loop if file name contains string

Posted: 09 Aug 2021 03:00
by aGerman
FWIW: It's been also for a reason that variable !name! exists. You'll run into trouble once a file name contains exclamation points. I told you about it already.

Steffen

Re: Repeating loop if file name contains string

Posted: 09 Aug 2021 03:55
by AlphaInc.
Yeah that worked. Thank you again.