Page 1 of 1

AUTO Convert MKV, AVI etc to MP4 Using Sonarr and SabNzbd

Posted: September 29th, 2016, 2:01 pm
by BrooBee
Hi,

I found this little script that I use after a TV-Show or a Movie etc is downloaded.

It works in Windows and is easy to change to fit your wishes.

It converts MKV or AVI to MP4, can be edited to convert more formats.

I have setup Sonarr to check for TV-Shows with indexers to find them, then Sonarr tells Sabnzbd to download them and execute the script to convert the TV-Shows to MP4, then the TV-Show gets moved to the right folder by Sonarr, Sonarr and Sabnzb deletes the files you dont want and only keep the TV-Show MP4.

It works with Movies etc too.

I hope someone has any use of it.

Code: Select all

@ECHO OFF
ECHO.
ECHO Begin SABPostProccessVideo - Remux MKV to MP4
ECHO.

REM Change these variables to match your system
SET FFMPEG=D:\ffmpeg\bin\ffmpeg.exe
SET OldAVI=avi
SET OldMKV=mkv
SET NewFormat=mp4

REM You shouldn't need to edit anything below here. Only if you add another format (Container) OldASF, OldWMV etc.

ECHO Looking in "%~1" for %OldAVI% or %OldMKV% files. Using %FFMPEG% to convert %OldAVI% or %OldMKV% to %NewFormat%...
ECHO.
ECHO Deleting unnecessary Files...
ECHO.
del /Q /F "%~1\*.*sample*","%~1\*.idx","%~1\*.sub","%~1\*.srr","%~1\*.jpg","%~1\*.url","%~1\*.pdf"
ECHO.
ECHO These are the files to convert:
ECHO.
for %%i IN ("%~1\*.%OldAVI%","%~1\*.%OldMKV%") DO (ECHO "%%i")
ECHO.
ECHO.
ECHO Starting Conversion (If there are any files)
ECHO.
ECHO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~START CONVERTING~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for %%i IN ("%~1\*.%OldAVI%","%~1\*.%OldMKV%") DO (%FFMPEG% -y -i "%%i" -c:v copy -c:a libfdk_aac "%~1\%%~ni.%NewFormat%")

REM Pause for 5 seconds once processing is complete to let things settle a bit

PING 127.0.0.1 -n 1 -w 5000 >NUL

REM This part checks to see if the old format files were converted to new format
ECHO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~END CONVERTING~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ECHO.
ECHO Checking for new format files in %~1
ECHO.
IF EXIST "%~1\*.%NewFormat%" (
	ECHO.
    ECHO Found %NewFormat% in folder!
	ECHO.
    ECHO Deleting old files then
    ECHO.
    ECHO Pause for 5 seconds before trying to delete files
	ECHO.
    PING 127.0.0.1 -n 1 -w 5000 >NUL    
    ECHO Deleting %OldAVI% or %OldMKV% and unnecessary files! Change the del command below, if you want to add or remove files to delete or keep.
	ECHO.
    del /Q /F "%~1\*.%OldAVI%","%~1\*.%OldMKV%","%~1\*.*sample*","%~1\*.idx","%~1\*.sub","%~1\*.srr","%~1\*.par2","%~1\*.jpg","%~1\*.url","%~1\*.pdf"
)
ECHO.
ECHO Done!
If you dont have "lifdk_aac" you can replace it with "aac"

Works now with Sorting in Sabnzbd, my settings are:

Image

Copy the code above, save to a file, for example convert.bat, put the file (convert.bat) in your Sabznbd Script folder.

In Sabnzbd setup your categories and choose the Script file "Convert.bat" click save to the right of that column.

Here is a result in Sabnzbd Log:

Code: Select all

Begin SABPostProccessVideo - Remux MKV to MP4

Looking in "F:\MOVIES" for avi or mkv files. Using D:\ffmpeg\bin\ffmpeg.exe to convert avi or mkv to mp4...

These are the files to convert:

"F:\MOVIES\THIS IS A TEST FILE (2016).mkv"


Starting Conversion (If there are any files)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~START CONVERTING~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ffmpeg version N-81884-ge5bbedf Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.9.3 (GCC)
  configuration: --arch=x86_64 --target-os=mingw32 --cross-prefix=/home/USER/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/bin/x86_64-w64-mingw32- --pkg-config=pkg-config --disable-w32threads --enable-libsoxr --enable-fontconfig --enable-libass --enable-libbluray --enable-iconv --enable-libtwolame --extra-cflags=-DLIBTWOLAME_STATIC --enable-libzvbi --enable-libcaca --enable-libmodplug --extra-libs=-lstdc++ --extra-libs=-lpng --enable-decklink --extra-libs=-loleaut32 --enable-libmp3lame --enable-version3 --enable-zlib --enable-librtmp --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libopenjpeg --enable-gnutls --enable-libgsm --enable-libfreetype --enable-libopus --enable-bzlib --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-libschroedinger --enable-libvpx --enable-libilbc --enable-libwavpack --enable-libwebp --enable-libgme --enable-dxva2 --enable-avisynth --enable-gray --enable-libopenh264 --enable-libebur128 --enable-netcdf --enable-libflite --enable-lzma --enable-libsnappy --enable-libzimg --enable-gpl --enable-libx264 --enable-libx265 --enable-frei0r --enable-filter=frei0r --enable-librubberband --enable-libvidstab --enable-libxavs --enable-libxvid --enable-libmfx --extra-libs=-lpsapi --extra-libs=-lspeexdsp --extra-cflags='-mtune=core2' --extra-cflags=-O3 --enable-static --disable-shared --prefix=/home/USER/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32 --enable-nonfree --enable-libfdk-aac --enable-runtime-cpudetect
  libavutil      55. 32.100 / 55. 32.100
  libavcodec     57. 60.101 / 57. 60.101
  libavformat    57. 51.102 / 57. 51.102
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 63.100 /  6. 63.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  2.100 /  2.  2.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, matroska,webm, from 'F:\MOVIES\THIS IS A TEST FILE (2016).mkv':
  Metadata:
    title           : THIS IS A TEST FILE 2016
    ENCODER         : Lavf56.40.101
  Duration: 00:06:30.56, start: 0.000000, bitrate: 3165 kb/s
    Stream #0:0(eng): Video: h264 (High), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
    Metadata:
      LANGUAGE        : eng
      BPS             : 5856854
      BPS-eng         : 5856854
      ENCODER         : Lavc56.60.100 libx264
      DURATION-eng    : 00:06:30.557000000
      NUMBER_OF_FRAMES: 11705
      NUMBER_OF_FRAMES-eng: 11705
      NUMBER_OF_BYTES : 285929433
      NUMBER_OF_BYTES-eng: 285929433
      _STATISTICS_WRITING_APP: mkvmerge v9.3.1 ('Mask Machine') 64bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v9.3.1 ('Mask Machine') 64bit
      _STATISTICS_WRITING_DATE_UTC: 2016-08-15 11:13:52
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-08-15 11:13:52
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION        : 00:06:30.557000000
    Stream #0:1(eng): Audio: aac (LC), 44100 Hz, mono, fltp (default)
    Metadata:
      LANGUAGE        : eng
      BPS             : 191999
      BPS-eng         : 191999
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION-eng    : 00:06:30.536000000
      NUMBER_OF_FRAMES: 16819
      NUMBER_OF_FRAMES-eng: 16819
      NUMBER_OF_BYTES : 9372852
      NUMBER_OF_BYTES-eng: 9372852
      _STATISTICS_WRITING_APP: mkvmerge v9.3.1 ('Mask Machine') 64bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v9.3.1 ('Mask Machine') 64bit
      _STATISTICS_WRITING_DATE_UTC: 2016-08-15 11:13:52
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-08-15 11:13:52
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION        : 00:06:30.536000000
    Stream #0:2(eng): Subtitle: subrip (default)
    Metadata:
      title           : Color Yellow Forced
      LANGUAGE        : eng
      BPS             : 213
      BPS-eng         : 213
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION-eng    : 00:06:23.233000000
      NUMBER_OF_FRAMES: 147
      NUMBER_OF_FRAMES-eng: 147
      NUMBER_OF_BYTES : 10231
      NUMBER_OF_BYTES-eng: 10231
      _STATISTICS_WRITING_APP: mkvmerge v9.3.1 ('Mask Machine') 64bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v9.3.1 ('Mask Machine') 64bit
      _STATISTICS_WRITING_DATE_UTC: 2016-08-15 11:13:52
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-08-15 11:13:52
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION        : 00:06:23.633000000
    Stream #0:3(eng): Subtitle: subrip
    Metadata:
      title           : No Forced Color
      LANGUAGE        : eng
      BPS             : 124
      BPS-eng         : 124
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION-eng    : 00:06:23.233000000
      NUMBER_OF_FRAMES: 147
      NUMBER_OF_FRAMES-eng: 147
      NUMBER_OF_BYTES : 5968
      NUMBER_OF_BYTES-eng: 5968
      _STATISTICS_WRITING_APP: mkvmerge v9.3.1 ('Mask Machine') 64bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v9.3.1 ('Mask Machine') 64bit
      _STATISTICS_WRITING_DATE_UTC: 2016-08-15 11:13:52
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-08-15 11:13:52
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION        : 00:06:23.633000000
Output #0, mp4, to 'F:\MOVIES\THIS IS A TEST FILE (2016).mp4':
  Metadata:
    title           : THIS IS A TEST FILE 2016
    encoder         : Lavf57.51.102
    Stream #0:0(eng): Video: h264 (High) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 29.97 fps, 29.97 tbr, 16k tbn, 1k tbc (default)
    Metadata:
      LANGUAGE        : eng
      BPS             : 5856854
      BPS-eng         : 5856854
      ENCODER         : Lavc56.60.100 libx264
      DURATION-eng    : 00:06:30.557000000
      NUMBER_OF_FRAMES: 11705
      NUMBER_OF_FRAMES-eng: 11705
      NUMBER_OF_BYTES : 285929433
      NUMBER_OF_BYTES-eng: 285929433
      _STATISTICS_WRITING_APP: mkvmerge v9.3.1 ('Mask Machine') 64bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v9.3.1 ('Mask Machine') 64bit
      _STATISTICS_WRITING_DATE_UTC: 2016-08-15 11:13:52
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-08-15 11:13:52
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION        : 00:06:30.557000000
    Stream #0:1(eng): Audio: aac (libfdk_aac) ([64][0][0][0] / 0x0040), 44100 Hz, mono, s16, 96 kb/s (default)
    Metadata:
      LANGUAGE        : eng
      BPS             : 191999
      BPS-eng         : 191999
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION-eng    : 00:06:30.536000000
      NUMBER_OF_FRAMES: 16819
      NUMBER_OF_FRAMES-eng: 16819
      NUMBER_OF_BYTES : 9372852
      NUMBER_OF_BYTES-eng: 9372852
      _STATISTICS_WRITING_APP: mkvmerge v9.3.1 ('Mask Machine') 64bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v9.3.1 ('Mask Machine') 64bit
      _STATISTICS_WRITING_DATE_UTC: 2016-08-15 11:13:52
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-08-15 11:13:52
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION        : 00:06:30.536000000
      encoder         : Lavc57.60.101 libfdk_aac
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (aac (native) -> aac (libfdk_aac))
Press [q] to stop, [?] for help
frame=  653 fps=0.0 q=-1.0 size=    8103kB time=00:00:21.68 bitrate=3060.8kbits/s speed=43.4x    
frame= 1275 fps=1275 q=-1.0 size=   15601kB time=00:00:42.44 bitrate=3011.3kbits/s speed=42.4x    
frame= 1910 fps=1273 q=-1.0 size=   23743kB time=00:01:03.63 bitrate=3056.7kbits/s speed=42.4x    
frame= 2584 fps=1292 q=-1.0 size=   30965kB time=00:01:26.12 bitrate=2945.4kbits/s speed=43.1x    
frame= 3247 fps=1299 q=-1.0 size=   39419kB time=00:01:48.25 bitrate=2983.1kbits/s speed=43.3x    
frame= 3854 fps=1285 q=-1.0 size=   48027kB time=00:02:08.49 bitrate=3061.9kbits/s speed=42.8x    
frame= 4431 fps=1266 q=-1.0 size=   55795kB time=00:02:27.74 bitrate=3093.6kbits/s speed=42.2x    
frame= 5058 fps=1264 q=-1.0 size=   62637kB time=00:02:48.66 bitrate=3042.2kbits/s speed=42.2x    
frame= 5643 fps=1254 q=-1.0 size=   70056kB time=00:03:08.18 bitrate=3049.6kbits/s speed=41.8x    
frame= 6270 fps=1254 q=-1.0 size=   77364kB time=00:03:29.11 bitrate=3030.7kbits/s speed=41.8x    
frame= 6915 fps=1257 q=-1.0 size=   85161kB time=00:03:50.63 bitrate=3024.9kbits/s speed=41.9x    
frame= 7533 fps=1255 q=-1.0 size=   95573kB time=00:04:11.25 bitrate=3116.1kbits/s speed=41.9x    
frame= 8200 fps=1261 q=-1.0 size=   99975kB time=00:04:33.50 bitrate=2994.4kbits/s speed=42.1x    
frame= 8840 fps=1263 q=-1.0 size=  107529kB time=00:04:54.86 bitrate=2987.3kbits/s speed=42.1x    
frame= 9404 fps=1254 q=-1.0 size=  114037kB time=00:05:13.68 bitrate=2978.2kbits/s speed=41.8x    
frame= 9877 fps=1235 q=-1.0 size=  119522kB time=00:05:29.46 bitrate=2971.9kbits/s speed=41.2x    
frame=10417 fps=1225 q=-1.0 size=  127363kB time=00:05:47.48 bitrate=3002.6kbits/s speed=40.9x    
frame=11009 fps=1223 q=-1.0 size=  135323kB time=00:06:07.23 bitrate=3018.7kbits/s speed=40.8x    
frame=11705 fps=1233 q=-1.0 Lsize=  146640kB time=00:06:30.53 bitrate=3076.0kbits/s speed=41.1x    
video:141511kB audio:4588kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.370807%
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~END CONVERTING~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Checking for new format files in F:\MOVIES


Found mp4 in folder!

Deleting old files then

Pause for 5 seconds before trying to delete files

Deleting avi or mkv and unnecessary files! Change the del command below, if you want to add or remove files to delete or keep.


Done!

Happy Downloading :)


AND ALL THANKS GOES TO porp in this Thread:

https://www.reddit.com/r/usenet/comment ... ically_in/

Thanks A LOT porp, Awesome 8)

P.S Updated script 8 October 2016 D.S

Re: AUTO Convert MKV, AVI etc to MP4 Using Sonarr and SabNzb

Posted: October 6th, 2016, 4:29 am
by BrooBee
Hi again,

Sorry for Double-post!


When I download a Movie via an .nzb file, I have setup Sabnzbd Sorting for Movies and setup categories.

All is well until my Script (above) is converting the movie to .mp4, it renames it like this:

Sabnzbd Sorting and Category renaming:

Amateur Night (2016).mkv

My Script after converting:

Amateur Night (2016).mkv.mp4

Is there anyone who can check my script to see what I can do in the end of this command:

for %%i IN ("%~1\*.%OldAVI%","%~1\*.%OldMKV%") DO (%FFMPEG% -i "%%i" -c:v copy -c:a libfdk_aac "%%i.%NewFormat%")

I have tried %%~ni and it makes the Movie ends up in Sabnzbd Install folder, BUT it is renamed perfectly :D

Re: AUTO Convert MKV, AVI etc to MP4 Using Sonarr and SabNzb

Posted: October 6th, 2016, 9:27 pm
by ALbino
The only thing I can think of is to strip the last 4 characters, which is doable for normal variables, but I think might not work with %%i, or at least would get real messy real fast. Examples on how to rename variables:

http://ss64.com/nt/syntax-replace.html

Since you got the script from reddit originally, maybe try the Batch subredddit:

https://www.reddit.com/r/Batch/

Re: AUTO Convert MKV, AVI etc to MP4 Using Sonarr and SabNzb

Posted: October 7th, 2016, 7:43 pm
by BrooBee
ALbino wrote:The only thing I can think of is to strip the last 4 characters, which is doable for normal variables, but I think might not work with %%i, or at least would get real messy real fast. Examples on how to rename variables:

http://ss64.com/nt/syntax-replace.html

Since you got the script from reddit originally, maybe try the Batch subredddit:

https://www.reddit.com/r/Batch/
Hi,

Thanks ALbino I will have a check there to see if I find a solution :)

Re: AUTO Convert MKV, AVI etc to MP4 Using Sonarr and SabNzb

Posted: October 7th, 2016, 9:49 pm
by BrooBee
Hi,

I found a solution with Sabnzbd's own Post-processing :D

for %%i IN ("%~1\*.%OldAVI%","%~1\*.%OldMKV%") DO (%FFMPEG% -i "%%i" -c:v copy -c:a libfdk_aac "%1\%3.mp4")

%1=The final directory of the job (full path)
and
%3=Clean version of the job name (no path info and ".nzb" removed)

BUT...

I can NOT have Sabnzbd's Sorting Movies active :(

Because when Sabnzb is done with sorting the Parameters %1 and %3 does not work they have only the info BEFORE sorting is done.

For example:

Original file name: This.Movie.Is.Fake.2014.DVDRip.x264-GROUP.mkv
Sorting: This Movie Is Fake (2014).mkv

When my script search for the file to convert, it can not find it because of the Sorting Rename and fails.

Any suggestions?

Re: AUTO Convert MKV, AVI etc to MP4 Using Sonarr and SabNzb

Posted: October 8th, 2016, 3:26 am
by shypike
The idea behind user scripting is that it does it's own "sorting".
SABnzbd wouldn't be able to supply the right info always, because it sends folder names, not file names.
Maybe we could do something in a later release, but that would be quite a bit of work
and likely incompatible with current scripts.

Re: AUTO Convert MKV, AVI etc to MP4 Using Sonarr and SabNzb

Posted: October 8th, 2016, 4:19 am
by BrooBee
shypike wrote:The idea behind user scripting is that it does it's own "sorting".
SABnzbd wouldn't be able to supply the right info always, because it sends folder names, not file names.
Maybe we could do something in a later release, but that would be quite a bit of work
and likely incompatible with current scripts.
That is true tho :)

Maybe the sorting could come after the User Scripts?

Re: AUTO Convert MKV, AVI etc to MP4 Using Sonarr and SabNzb

Posted: October 8th, 2016, 6:32 am
by shypike
BrooBee wrote: Maybe the sorting could come after the User Scripts?
But SABnzbd cannot know what the user script does.
It may mess up things.

Re: AUTO Convert MKV, AVI etc to MP4 Using Sonarr and SabNzb

Posted: October 8th, 2016, 6:40 am
by BrooBee
shypike wrote:
BrooBee wrote: Maybe the sorting could come after the User Scripts?
But SABnzbd cannot know what the user script does.
It may mess up things.
Ah, yeah, not easy to know that tho :D

I found a solution to my script tho, YaY :D

Re: AUTO Convert MKV, AVI etc to MP4 Using Sonarr and SabNzbd

Posted: October 18th, 2024, 9:03 am
by travisk
Thank BrooBee

Having issues with plex being able to direct stream 1080p hvec h265 movies in mp4 format myself. Used a modified version of your script to have mkvmerge "remux" the promlematic mp4's into a mkv container.

I was just having sonnarr & radar ignore available downloads with hvec, h265, h265+ in their titles but that was making it where titles wouldn't download because that's all that was available. Lots of titles were having to be download and remuxed manually.

If you or anyone is better with batch scripting id love to just have the script search the title for *hvec* or *h265* + *1080* that has a extension of mp4 seeing these are the only files plex has issue playing. For now this one just remuxes everything that ends in mp4 which is fine. a 4gb file only takes like 15 secs for my pc to "remux". Wouldnt mind having somthing a little cleaner tho.

Here's the modified code im using if it might help anyone else..

Code: Select all

u/ECHO OFF
ECHO.
ECHO Begin SABPostProccessVideo - Remux MKV to MP4
ECHO.

REM Change these variables to match your system
SET mkvmergeloc="C:\\Program Files\\MKVToolNix\\mkvmerge.exe"
SET oldmp4=mp4
SET NewFormat=mkv

REM You shouldn't need to edit anything below here. Only if you add another format (Container) OldASF, OldWMV etc.

ECHO Looking in "%~1" for %oldmp4% files. Using MKVMERGE to convert mp4's to MKV format...
ECHO.
ECHO Deleting unnecessary Files...
ECHO.
del /Q /F "%~1\*.*sample*","%~1\*.idx","%~1\*.sub","%~1\*.srr","%~1\*.jpg","%~1\*.url","%~1\*.pdf"
ECHO.
ECHO These are the files to convert:
ECHO.
for %%i IN ("%~1\*.%oldmp4%") DO (ECHO "%%i")
ECHO.
ECHO.
ECHO Starting Conversion (If there are any files)
ECHO.
ECHO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~START CONVERTING~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for %%i IN ("%~1\*.%oldmp4%") DO (%mkvmergeloc% -o "%~1\%%~ni.%NewFormat%" "%%i")

REM Pause for 5 seconds once processing is complete to let things settle a bit

PING 127.0.0.1 -n 1 -w 5000 >NUL

REM This part checks to see if the old format files were converted to new format
ECHO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~END CONVERTING~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ECHO.
ECHO Checking for new format files in %~1
ECHO.
IF EXIST "%~1\*.%NewFormat%" (
 ECHO.
    ECHO Found %NewFormat% in folder!
 ECHO.
    ECHO Deleting old files then
    ECHO.
    ECHO Pause for 5 seconds before trying to delete files
 ECHO.
    PING 127.0.0.1 -n 1 -w 5000 >NUL    
    ECHO Deleting %oldmp4% and unnecessary files! Change the del command below, if you want to add or remove files to delete or keep.
 ECHO.
    del /Q /F "%~1\*.%oldmp4%","%~1\*.*sample*","%~1\*.idx","%~1\*.sub","%~1\*.srr","%~1\*.par2","%~1\*.jpg","%~1\*.url","%~1\*.pdf"
)
ECHO.
ECHO Done!