Hi,
Novice batch user here, but I follow directions well. I am using the excellent FFmpeg open-source video and audio converter. My batch file works fine for automating conversion of .MKV files to .MP4 so that my son can put his favorite shows on his PlayStation Vita (yes, it's an old gadget, but he loves it.) The converted files play perfectly on the handheld device. But I am interested in streamlining future conversions so that a source file is deleted as soon as it has been successfully converted.
The script right now processes the file, then it leaves the source file. I've hunted around for some solutions, but I haven't been able to get any of the suggestions I've seen to work. The suggestions mainly center around using "if not errorlevel 1 if exist "%%~dpnF.mp4" del /q "%%F" variants, but unfortunately I just don't have the proficiency to incorporate it correctly.
Can anybody help me out?
Here's my script.
for /r H:\Convert\Input\ %%a in (*.mkv) do "C:\ProgramsMJ\winff\ffmpeg.exe" -itsoffset -0.275 -i "%%a" -y -crf 20.0 -vcodec libx264 -filter:v scale=1280:720 -preset slow -acodec libvo_aacenc -ar 48000 -b:a 128k -coder 1 -flags +loop -cmp chroma -partitions +parti4x4+partp8x8+partb8x8 -me_method hex -subq 6 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -threads 0 "%%~pa%%~na.mp4"
Delete Files After Processing FFmpeg Conversion
Moderator: DosItHelp
Re: Delete Files After Processing FFmpeg Conversion
Actually, I figured it out. This deletes the files after they are processed by FFmpeg. It was simpler than I thought.
H:
cd \Convert\Input
for %%f in (*.mkv) do (
"C:\ProgramsMJ\winff\ffmpeg.exe" -itsoffset -0.275 -i "%%~nxf" -y -crf 20.0 -vcodec libx264 -filter:v scale=1280:720 -preset slow -acodec libvo_aacenc -ar 48000 -b:a 128k -coder 1 -flags +loop -cmp chroma -partitions +parti4x4+partp8x8+partb8x8 -me_method hex -subq 6 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -threads 0 "H:\Convert\Output\%%~nf.mp4"
del "%%~f"
)
H:
cd \Convert\Input
for %%f in (*.mkv) do (
"C:\ProgramsMJ\winff\ffmpeg.exe" -itsoffset -0.275 -i "%%~nxf" -y -crf 20.0 -vcodec libx264 -filter:v scale=1280:720 -preset slow -acodec libvo_aacenc -ar 48000 -b:a 128k -coder 1 -flags +loop -cmp chroma -partitions +parti4x4+partp8x8+partb8x8 -me_method hex -subq 6 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -threads 0 "H:\Convert\Output\%%~nf.mp4"
del "%%~f"
)