Solved How to remove file extension from the filename?

May 20, 2013 at 13:31:24
Specs: Windows XP
Hello fellas. I wrote some simple batch file that converts any audio/video files to .ogg (audio) format. For example music off youtube which is in .flv format. Here's the script:
set ogg_rate=1.3
set source_dir=f:\music
set dest_dir=f:\music\out
set my_temp=f:\temp

Rem Go to source dir
cd /d %source_dir%
for %%f in (*.*) do (

Rem Extract audio from avi file using ffmpeg
c:\encode\ffmpeg.exe -i "%source_dir%\%%f" "%my_temp%\%%f.wav"

rem Encode the audio with OGG encoder using 1.3 quality setting
cd /d %my_temp%
c:\encode\oggenc2.exe -q %ogg_rate% -o "%dest_dir%\%%f.ogg" "%my_temp%\%%f.wav"

rem delete all temp files
cd /d %my_temp%
del *.* /q

It works file, but I cannot figure out how to remove the unnecessary extension.
For example, input file is "file.flv" then after converting to wave it will be file.flv.wav than, after converting it to .ogg it will be file.flv.ogg
How to get the file.ogg - without ".flv"
BTW- instead of .flv it can me .mp4, .avi or another extension. Thanks.

See More: How to remove file extension from the filename?

Report •

May 20, 2013 at 14:06:25
✔ Best Answer
for %%f in (*.*) do (
c:\encode\ffmpeg.exe -i "%source_dir%\%%f" "%my_temp%\%%~nf.wav"

cd /d %my_temp%
c:\encode\oggenc2.exe -q %ogg_rate% -o "%dest_dir%\%%~nf.ogg" "%my_temp%\%%~nf.wav"

see: FOR /?, third page i think, it shows all the tilde enhancements.

Report •

May 20, 2013 at 14:13:56
Thanks. That worked great.

Report •
Related Solutions

Ask Question