[英]Windows Batch file— Multiple selection
I had a question regarding batch file. 我对批处理文件有疑问。 I have a batch script which runs on "right click" of a directory.
我有一个在目录的“右键单击”上运行的批处理脚本。
But If i have selected MULTIPLE directories, the script executes for each selection one by one.. Is it possible to perhaps integrate this in a way that the script executes for all selections ONCE ? 但是,如果我选择了MULTIPLE目录,该脚本将为每个选择一个接一个地执行。是否有可能以一种脚本对所有选择一次执行的方式进行集成? Or perhaps I get the list of all selections in the batch script?
还是我可以在批处理脚本中获得所有选择的列表? (perhaps a change in registry? )
(也许注册表更改了?)
Thanks Saad 谢谢萨德
Yes, it's possible. 是的,有可能。 Paste a shortcut of your script to the
shell:sendto
folder . 将脚本的快捷方式粘贴到
shell:sendto
文件夹 。 Then: 然后:
Unfortunately, described method works not only for directories (folders): it accepts file names as well. 不幸的是,所描述的方法不仅适用于目录(文件夹):它还接受文件名。 You need to add some tests about validity of supplied names into your script.
您需要在脚本中添加一些有关所提供名称有效性的测试。
Below is a script used for testing (it distinguishes file
/ folder
/ unknown
individually): 以下是用于测试的脚本(它可以区分
file
/ folder
/ unknown
folder
):
@echo OFF
SETLOCAL enableextensions disabledelayedexpansion
echo(
echo before any shift
echo "%~nx0" [%~1] [%~2] [%~3] [%~4]
echo all %%* = %*
echo(
set /A "ii=0"
:loopfor
if "%~1"=="" goto :loopend
set /A "ii+=1"
If exist "%~1\*" (
echo folder %%%ii% = %1
) else (
If exist "%~1" (
echo file %%%ii% = %1
) else (
echo unknown %%%ii% = %1
)
)
SHIFT
goto :loopfor
:loopend
SHIFT
echo(
echo after all shifts: %ii% parameter^(s^)
echo "%~0" [%~1] [%~2] [%~3] [%~4]
echo all %%* = %*
ENDLOCAL
pause>NUL
goto :eof
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.