开发者

Batch script file to convert every file in every folder one at a time

开发者 https://www.devze.com 2023-04-12 06:33 出处:网络
What im trying to do is convert .ogg files stored in many different folders. What i NEED the batch script to do is go from the first folder and file , convert it and only then move on to the next file

What im trying to do is convert .ogg files stored in many different folders. What i NEED the batch script to do is go from the first folder and file , convert it and only then move on to the next file in the folder. Also during the conversion process a wave file is created, so i need it to be deleted at the end of the files conversion along with the original .ogg file. This is my code so far. It goes through every folder and file performing the oggdec producing massive amounts of wave files. I need the script to only do one folder and one file at a time

for /r %%i in (*.ogg) do oggdec "%%i"
for /r %%i in (*.ogg) do del "%%i"
for /r %%i in (*.wav) do lame -m m   "%%i"
for /r %%i in (*.wav) do del "%%i"

@echo off
etlocal enabledelayedexpansion
set deletestring=.wav
echo Ready to start
echo.

echo.
for /f "delims==" %%F in ('dir /b /s /a-d ^| find "%deletestring%"') do (
    set oldfilename=%%~nxF
    set pathname=%%~dpF
    set newfilename=!oldfilename:%deletestring%=!
    Ren "!pathname!!oldfilename!" "!newfilename!"
    )
echo.
echo All done

(

This code above almost works in that the end result is working, but unfortunately i need it to convert only one file at a time and delete the original .ogg and .wav before moving to the next .ogg file.So i need it to follow this rule Take the first folder and the first .ogg file do oggdec on file producing the .wav del the .ogg file do lame -m m on the .wav file producin开发者_StackOverflowg the .mp3 file del the .wav file move on to the next .ogg file until all files in the folder are converted then move on to the next folder which may not be in the same folder. An example folder structure.

Sounds/voice/greek
Sounds/voice/English
Sounds/voice/russion


Using enhanced substitution for FOR variable:

  • %%~di - drive letter
  • %%~pi - file path
  • %%~ni - file name without extension

Resulting script is:

for /r %%i in (*.ogg) do (
  oggdec "%%i"
  del "%%i"
  lame -m m "%%~dpni.wav"
  del "%%~dpni.wav"
)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号