Lets say I want to create a batch file. I work with video files and I use this well known tool MediaInfo. And it has a CLI version on Windows.
Lets say I want to rename bunch of files in a folder. So I run this:
for /r %%i in (*.mkv) do call ren "%%i" "renamed_files.mkv"
So what it does is that it picks up all .mkv
files in the dir and renames it. That's great.
But what if I want to rename only specific .mkv
files and not all of them? E.g. I have multiple .mkv
files that has audio and some that doesn't. And lets say I want to rename only those that have audio. So to do that, I need to use some solution to scan/detect which files has audio. And to do that I thought why not use MediaInfo CLI. So we run this command:
mediainfo --inform="Audio;%ID%" file.mkv
And all it does, it prints 2
which is the ID of the audio track, which we could use to confirm that audio exists and the .mkv
file should be picked up for renaming. And if there is no audio, it prints nothing, empty line, so those files should be skipped.
Makes sense and all, but I can't figure out how to wrap it up in if
statements and make it work since its all new to me, I've been learning command prompt and batch files for 2 days now.
Or maybe someone knows even better solution. Except I'm not interested on installing 3rd party software with GUIs for that.
Cheers!