Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 在批处理文件中使用带有通配符的explorer.exe_Batch File_Cmd_Windows Explorer - Fatal编程技术网

Batch file 在批处理文件中使用带有通配符的explorer.exe

Batch file 在批处理文件中使用带有通配符的explorer.exe,batch-file,cmd,windows-explorer,Batch File,Cmd,Windows Explorer,我的问题是在批处理文件中使用select参数启动explorer.exe。我用这个: if exist "!SATIR!\!SATIR:~20,-23!.mp4" (explorer.exe /select, "!SATIR!\!SATIR:~20,-23!.mp4") else (explorer.exe /select, "!SATIR!\!SATIR:~20,-23!.mkv") 它可以工作,但我不想依赖于特定的文件扩展名。我想对所有扩展avi、wmv等使用通配符 使用类似于:if ex

我的问题是在批处理文件中使用select参数启动explorer.exe。我用这个:

if exist "!SATIR!\!SATIR:~20,-23!.mp4" (explorer.exe /select, "!SATIR!\!SATIR:~20,-23!.mp4") else (explorer.exe /select, "!SATIR!\!SATIR:~20,-23!.mkv")
它可以工作,但我不想依赖于特定的文件扩展名。我想对所有扩展avi、wmv等使用通配符

使用类似于:if exist!萨蒂尔!萨蒂尔:~20,-23!*explorer.exe/选择!萨蒂尔!萨蒂尔:~20,-23!*不起作用。explorer.exe部分失败。到目前为止我什么也没有得到。有可能吗

附言!萨蒂尔!变量包含这些mp4和mkv文件的本地地址。它类似于:F:\Movies\000y.001y\The.Lord.of.The.Rings.The.Return.of.The.King.2003{0167260}[00087]


附言!萨蒂尔:~20,-23!eq The.Lord of.The.Rings.The.The.The.The.King的.Return.of.The.The.Windows资源管理器不支持option/select的通配符,因为此选项需要目录路径、文件名(带路径或不带路径,具体取决于根目录的用法)或对象名。有关和更高版本的Windows资源管理器,请参见Windows资源管理器的命令行选项页。据我所知,使用此命令行选项无法选择多个文件

但是批处理文件仍然可以在测试是否存在时使用文件扩展名的通配符,然后使用文件的全名启动Windows资源管理器,并首先匹配文件规范

下面是一个批处理文件示例:

@echo off
set SATIR=F:\Movies\000y.001y\The.Lord.of.the.Rings.The.Return.of.the.King.(2003){0167260}[00087]
set FILESPEC=%SATIR:~20,-23%.*
if exist "%SATIR%\%FILESPEC%" (
    for %%f in ("%SATIR%\%FILESPEC%") do (
        %windir%\explorer.exe /select,"%%f"
        goto :LoopExit
    )
)
:LoopExit
set FILESPEC=
set SATIR=
嗯,if条件在这里或多或少是无用的。下面的批处理文件上的行为相同

@echo off
set SATIR=F:\Movies\000y.001y\The.Lord.of.the.Rings.The.Return.of.the.King.(2003){0167260}[00087]
set FILESPEC=%SATIR:~20,-23%.*
for %%f in ("%SATIR%\%FILESPEC%") do (
    %windir%\explorer.exe /select,"%%f"
    goto :LoopExit
)
:LoopExit
set FILESPEC=
set SATIR=