News:

--

Main Menu

Help with batch file

Started by scar69, August 05, 2025, 05:59:57 PM

Previous topic - Next topic

scar69

I am trying to convert some classic 80's adult from avi to mp4. Through a google search I found a batch script that does work but the only issue I am having is the resulting file is named *****.avi. Is there a way for the script to remove the .avi from the file name so I don't need to manually rename each file? Here is the script I am using...

set avidemux="C:\Program Files\Avidemux 2.8 VC++ 64bits\avidemux.exe"

set outputformat=MP4

for %%f in (*.avi) do %avidemux% --output-format %outputformat% --load "%%f" --save "%%f.mp4" --quit

TIA

dosdan2

Quote from: scar69 on August 05, 2025, 05:59:57 PMfor %%f in (*.avi) do %avidemux% --output-format %outputformat% --load "%%f" --save "%%f.mp4" --quit

Use %%F and "%%~dpnF.mp4". The use of upper-case F is importand here so the command interpreter does not  confuse it with %%~f which is also a valid parameter extension.

Here's a test example, with 5 AVIs in the current root directory of "D:". How not to include the ".avi" in the full pathname and include ".mp4" instead:

dir /b *.avi

! x264.avi
60frames.avi
Dream World 038.avi
GA1.avi
Testfile_atempo.avi

Create TEST1.BAT

@echo off
for %%F in (*.avi) do echo "%%~dpnF.mp4"

Run TEST1.BAT

"D:\! x264.mp4"
"D:\60frames.mp4"
"D:\Dream World 038.mp4"
"D:\GA1.mp4"
"D:\Testfile_atempo.mp4"

For an explanation of the parameter extensions used here, see https://ss64.com/nt/syntax-args.html


scar69