Find multiple strings

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Sounak@9434
Posts: 100
Joined: 16 Dec 2016 22:31

Find multiple strings

#1 Post by Sounak@9434 » 31 Mar 2017 04:48

So guys, I just downloaded a music pack from online yesterday. I extracted it and found 50 folders each with unique name and some with "!" name too. Inside each folder there is a separate audio and soundless video file. So to use external audio file using vlc I made a script.

Code: Select all

@echo off
for /f "tokens=*" %%z in ('dir /b') do (
   pushd "%%z"
   setlocal enabledelayedexpansion
   for /f "tokens=*" %%a in ('dir /b^|find ".mp3"') do set "msc=%%a"
   for /f "tokens=*" %%b in ('dir /b^|find ".avi"') do set "vid=%%b"
   if "!msc!" neq "" (
      if "!vid!" neq "" ("C:\Program Files\VideoLAN\VLC\vlc.exe" -f "!vid!" --input-slave="!msc!" vlc://quit) ELSE ("C:\Program Files\VideoLAN\VLC\vlc.exe" "!msc!" vlc://quit)
   )
   endlocal
   popd
)

The problem is that some music files are in *.ogg and some video files are in *.mp4
So how can I create a find command that will search for multiple strings. I don't want to create two separate find command as each folder contains many files and this will kill the performance. Maybe this would also work, if a find is successful it terminates the other one from use.

And as a side request, does anyone knows any command line utility that can join music file with video file?

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Find multiple strings

#2 Post by ShadowThief » 31 Mar 2017 08:09

Don't use find at all; dir can handle multiple wildcards.

Code: Select all

for /f "tokens=*" %%a in ('dir /b *.mp3 *.ogg') do set "msc=%%a"
for /f "tokens=*" %%b in ('dir /b *.avi *.mp4') do set "vid=%%b"

Samir
Posts: 384
Joined: 16 Jul 2013 12:00
Location: HSV
Contact:

Re: Find multiple strings

#3 Post by Samir » 13 Apr 2017 14:25

As far as the command line video/audio program, I believe ffmpeg has options for this.

Post Reply