问题描述
多线程部分已经replied这里伟大工程(感谢很多)
The multithreading part was already replied here and works great (thanks a lot to Magoo)
主要code
SET /a instances=%NUMBER_OF_PROCESSORS%
:: make a tempfile
:maketemp
SET "tempfile=%temp%\%random%"
IF EXIST "%tempfile%?" (GOTO maketemp) ELSE (ECHO.>"%tempfile%a")
::
:loop
SET "nextfile=%~1"
IF NOT DEFINED nextfile (
DEL "%tempfile%a*" >NUL 2>NUL
::ECHO all done
exit
)
FOR /L %%a IN (1,1,%instances%) DO (
IF NOT EXIST "%tempfile%a%%a" (
>"%tempfile%a%%a" ECHO.
START /B "Instance %%a" oneconversion.bat "%~1" "%tempfile%a%%a" %%a
SHIFT
GOTO loop
)
)
timeout /t 1 >NUL
GOTO loop
的 code例如oneconversion.bat
@ECHO OFF
SETLOCAL
CALL truepng.exe "%1"
CALL pngwolf.exe "%1"
DEL "%~2" >NUL 2>NUL
cls
exit
这工作到现在。
但是,当我保留使用命令的前10个参数。结果如何保留命令
But when I reserve first 10 parameters in use of commands.
How I reserve commands
FOR /f "TOKENS=1-11*" %%a in ("%*") DO (
SET filelist=%%l
)
SET varresize=%1
SHIFT
SET varincsmall=%1
SET varwidth=%2
SET varheight=%3
SET varjpegqa=%4
SET varjpegpr=%5
SET varjpegex=%6
SET varpngqa=%7
SET varpngcl=%8
SET varpngqt=%9
我不知道我该如何使用%文件清单%
主要code内。并确保与%文件清单%
不起作用替换%〜1
。看起来像我错过了点,但没有找到一条出路。
I don't know how can I use %filelist%
inside main code. And sure replacing %~1
with %filelist%
doesn't work. Looks like I missed a point and couldn't find a way out.
感谢大家帮助,或者至少尝试。
Thanks for everyone will help or at least try to.
推荐答案
在主脚本的开头添加您的变量初始化code,另外转向的命令行参数9次:
Add your variable initialization code at the start of the main script and shift the command line parameters additionally 9 times:
SET varresize=%1
SHIFT
SET varincsmall=%1
SET varwidth=%2
SET varheight=%3
SET varjpegqa=%4
SET varjpegpr=%5
SET varjpegex=%6
SET varpngqa=%7
SET varpngcl=%8
SET varpngqt=%9
for /L %%a in (1,1,9) do shift
这样你就不需要文件清单:
,我想。
这篇关于多线程批处理文件传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!