好的,所以我有一个Windows10 .bat脚本来转换一个文件夹中的所有类型的视频,然后用多个命令在另一个文件夹中使用HandbrakeCLI进行输出。
除此之外,我还想使用像BES这样的CPU使用限制器来控制HandbrakeCLI的CPU使用。
在每个文件被转换之后,我想向我自己发送一个Pushbullet通知,说明转换已经完成。
下面的代码帮助我实现了这一点,但是,我需要运行两次.bat文件才能开始,并且在一次迭代之后停止它。
最初在使用多个命令时遇到了问题,搜索和在命令之间使用"&“,没有joy。
我已经有了一个Powershell脚本,所以请不要建议使用Powershell,我不想使用它,因为Powershell脚本需要更高的特权,我不想再给它了。
FOR /R "D:\ToConvert" %%i IN (*.*) DO "C:\Program Files (x86)\BES_1.6.2\BES.exe" "C:\Program Files\Handbrake\HandBrakeCLI.exe" 33 --minimize & "C:\Program Files\HandBrake\HandBrakeCLI.exe" -i "%%i" -t 1 -c 1 -o "D:\Done\%%~ni.mp4" --preset="Normal" --optimize & powershell -ExecutionPolicy Bypass -command "D:\Scripts\SendPushBullet.ps1 "%%~ni" " Converted"" & taskkill /im BES.exe或
call "C:\Program Files (x86)\BES_1.6.2\BES.exe" "C:\Program Files\Handbrake\HandBrakeCLI.exe" 33 --minimize
for /r "D:\ToConvert" %%i IN (*) do (
"C:\Program Files\HandBrake\HandBrakeCLI.exe" -i "%%i" -o "D:\Done\%%~ni.mp4" --preset="Normal" --optimize
powershell -ExecutionPolicy Bypass -command "D:\Scripts\SendPushBullet.ps1 "%%~ni" " Converted""
)
taskkill /im BES.exe
exit /b//TODO
删除已转换的文件
Update:让它使用下面的代码工作,但是现在想要删除每个循环的"ToConvert“文件夹中转换的文件
start "" "C:\Program Files (x86)\BES_1.6.2\BES.exe" "C:\Program Files\Handbrake\HandBrakeCLI.exe" 33 --minimize
for /r "D:\ToConvert" %%i IN (*) do (
"C:\Program Files\HandBrake\HandBrakeCLI.exe" -i "%%i" -o "D:\Done\%%~ni.mp4" --preset="Normal" --optimize
powershell -ExecutionPolicy Bypass -command "D:\Scripts\SendPushBullet.ps1 "%%~ni" " Converted""
)
taskkill /im BES.exe发布于 2015-08-25 14:39:01
(下面的代码有效;)
start "" "C:\Program Files (x86)\BES_1.6.2\BES.exe" "C:\Program Files\Handbrake\HandBrakeCLI.exe" 33 --minimize
for /r "D:\ToConvert" %%i IN (*) do (
"C:\Program Files\HandBrake\HandBrakeCLI.exe" -i "%%i" -o "D:\Done\%%~ni.mp4" --preset="Normal" --optimize
powershell -ExecutionPolicy Bypass -command "D:\Scripts\SendPushBullet.ps1 "%%~ni" " Converted""
)
taskkill /im BES.exe
del /f /q "D:\ToConvert\*.*"发布于 2015-08-25 13:50:49
要从ToConvert中删除原始文件,只需在循环结束时添加一个del "%%i"。实际上,%%i拥有文件的绝对路径。
https://stackoverflow.com/questions/32195921
复制相似问题