Hello all,
I'm very new to the batch code scene and have been familiarizing myself lately will all the commands. I've been struggling to create a batch code which does the following:
Scans folder for any *.mkv files (will only be 1 in folder)
Takes file location and file name
inputs this command (replacing FILENAME with name from file): ffmpeg -i FILELOCATION\FILENAME.mkv -c:v copy -c:a copy FILENAME.mp4
renames FILENAME.mp4 to FILENAME.avi
It's basically a rewrite of this code, but in DOS (mines using ffmpeg instead of avconv)
#!/bin/bash
#avconv --help
IFS=$'\n'
clear
for filename in *.mkv
do
echo "$filename"
newfilename="${filename%.mkv}.mp4"
echo "${newfilename}"
avconv -i $filename -vcodec copy -acodec copy $newfilename
done
Any help would be greatly appreciated!!
Use FFmpeg to process a tree of MKV files
Moderator: DosItHelp
Re: Help with Batch code
Test this. It should create the AVI file in the same folder as the MKV folder.
Code: Select all
@echo off
for /r "c:\base\folder" %%a in (*.mkv) do (
ffmpeg -i "%%a" -c:v copy -c:a copy "%%~dpa\%%~na.avi"
)
Re: Help with Batch code
Works great!
Care to explain what this command is doing? %%~dpa\%%~na.avi
Thanks for the quick reply, I really appreciate it
Care to explain what this command is doing? %%~dpa\%%~na.avi
Thanks for the quick reply, I really appreciate it
Re: Help with Batch code
issue /? on forStyreman wrote:Care to explain what this command is doing? %%~dpa\%%~na.avi
Code: Select all
>for /?
Code: Select all
% ~ dI - expands% I to a drive letter
% ~ pI - expands% I to a path
% ~ nI - expands% I to a file name