0

指定したフォルダーごとにファイルごとに構成ファイルを作成するバッチスクリプトを作成しようとしています。

構成ファイルを作成した後、選択された構成ファイルを使用するプログラムを実行し、構成内の指定されたファイルを変換します。

ここに私の現在のコードがあります:

    :start
@echo off
cls
cd /d %~dp0
goto source

rem This sets up the working folder. I usually do this because I need to but I am 
rem not sure about it this time...

:source
echo Please select the folder with the ARF files in it.
set /p source=E.G. C:\Users\Elliot\Desktop\toconvert:
goto dest


rem This sets the folder location for the ARF files.
rem I am going to add a menu for simplicity sake later.


:dest
echo Please select where the mp4 files should appear.
set /p dest=E.G. C:\Users\Elliot\Desktop\Converted:
goto cfgname


rem This sets the output folder for the converted files.
rem Again I will make a menu in the future.


:cfgname


goto createcfg

rem this sets the name of the CFG that will be created for the ARF file


:createcfg
echo [Console] >> %MP4%.cfg
echo inputfile=%source%\1.arf >> MP4.cfg
echo media=MP4 >> MP4.cfg
echo showui=1 >> MP4.cfg
echo [UI] >> MP4.cfg
echo chat=1 >> MP4.cfg
echo qa=0 >> MP4.cfg
echo largeroutline=1 >> MP4.cfg
echo [MP4] >> MP4.cfg
echo outputfile=%dest%\1.mp4 >> MP4.cfg
echo width=1024 >> MP4.cfg
echo height=768 >> MP4.cfg
echo framerate=10 >> MP4.cfg


rem This makes the config file that is required by the player to convert

:convert
cd C:\programdata\webex\webex\500
nbrplay.exe -Convert "%cfg%"

:end
echo Thanks for using Elliot Labs Auto Converter.
echo for feature requests please email: elliot-labs@live.com
pause | echo Press any key to exit...
exit

:preloop
set num=0
goto loop

:loop
cls
echo %num%
pause
set /a num+=1
if %num%==6 (goto end) ELSE goto loop

これは 1 つのファイルに対してのみ機能します。フォルダ全体に適用するにはどうすればよいですか。

4

1 に答える 1

3
@echo off &setlocal
for %%a in ("%cd%\*.arf") do call:MakeCFG "%%~a"
goto:eof

:MakeCFG
setlocal
set "MP4=%~n1"
set "source=%~dp1"
set "filename=%~n1"
set "dest=X:\destination"

(
ECHO([Console]
ECHO(inputfile=%source%%filename%
ECHO(media=MP4
ECHO(showui=1
ECHO([UI]
ECHO(chat=1
ECHO(qa=0
ECHO(largeroutline=1
ECHO([MP4]
ECHO(outputfile=%dest%\%filename%.mp4
ECHO(width=1024
ECHO(height=768
ECHO(framerate=10
)>"%MP4%.cfg"
exit /b 0
于 2013-11-01T03:06:34.417 に答える