开发者

Batch How do i execute a command on every .m4p file in all Sub dir

开发者 https://www.devze.com 2023-01-16 02:14 出处:网络
Basically i want to run this in ever Sub folder for %%i in (*.m4a) do faad \"%%i\" for %%i in (*.wav) do oggenc \"%%i\"

Basically i want to run this in ever Sub folder

for %%i in (*.m4a) do faad "%%i"
for %%i in (*.wav) do oggenc "%%i"
for %%i in (*.m4a) do del "%%i"
for %%i in (*.wav) do del "%%i"

it works great but i have to manually change dir and re run eg.

cd res  
cd music
for %%i in (*.m4a) do faad "%%i"
for %%i in (*.wav) do oggenc "%%i"
for %%i in (*.m4a) do del "%%i"
for %%i in (*.wav) do del "%%i"
cd..
cd Sounds
for %%i in (*.m4a) do faad "%%i"
for %%i in (*.wav) do oggenc "%%i"
for %%i in (*.m4a) do del "%%i"
for %%i in (*.wav) do del "%%i"
cd..

and the list goes on. Problem is i have hundreds of sub folders, so it would take forever is there a way i can开发者_开发问答 run my little script automatically in All sub directory's starting with a defined dir

such as

for /f "usebackq delims=|" %%f in (`dir /b /s *.m4p`) do faad.exe "%%f"

Any help would be apreciated


I figured it out for my self All i have to do is point to the dir with the m4a files and the code does the rest, It will look though every sub folder also

cd Music

for /r %%i in (*.m4a) do faad "%%i"

for /r %%i in (*.wav) do oggenc "%%i"

for /r %%i in (*.m4a) do del "%%i"

for /r %%i in (*.wav) do del "%%i"

For your information.This scpipt Looks for m4a files, uses faad to convert to wave file`s The wave files are then get converted to Ogg format using oggenc The m4a files are deleted The wave files are deleted


It is safer to do the following so that you won't lose your source .m4a files if conversion process fails:

for /r %%i in (*.m4a) do call :convert %%i
goto :end

:convert
  set M4A=%1
  set WAV=%M4A:.m4a=.wav%
  set OGG=%M4A:.m4a=.ogg%
  faad %M4A%
  if not exist %WAV% (echo %M4A% not converted.) else (oggenc %WAV%      )
  if not exist %OGG% (echo %WAV% not converted.) else (del    %M4A% %WAV%) 
goto :EOF

:end
0

精彩评论

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