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

这仅适用于一个文件。如何使其适用于整个文件夹。

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 回答