如何打开在CMD

时间:2017-10-26 08:18:01

标签: batch-file command-prompt

我使用

在命令提示符中搜索了一个文件
dir /s *584.pdf

找到了文件,结果如下

 Volume in drive Z is New Volume
 Volume Serial Number is E49F-4208

 Directory of Z:\OHE_Design\DFCC\EMP-4 OHE\Submissions\References\Received\CTP-1 & 2\05-Bridge Mast files\CTP 1 & 2 DETAILS\OHE approval letters\L-NKC-SLT-PMC-1612-48

12/14/2016  05:11 PM         8,180,090 2-MB-13-011-OHE_Rev.0 584.pdf
               1 File(s)      8,180,090 bytes

     Total Files Listed:
               1 File(s)      8,180,090 bytes
               0 Dir(s)  47,574,523,904 bytes free

现在,我想打开我搜索过的文件,是否有任何命令可以执行此操作?我该怎么办?

2 个答案:

答案 0 :(得分:2)

for /r "Z:\OHE_Design" %%a in ("*584.pdf") do (
   start "" "%%~fa"
)

试试这个。

答案 1 :(得分:0)

我尝试了一些代码,它似乎对我很有用。

@echo off
set /p search="Enter the file : "
cd "C:\users\suneel\desktop\Potato 23"
dir /s /b /a-d "*%search%*.pdf">"test.txt"
if '%ERRORLEVEL%'=='0' GOTO OPEN
if '%ERRORLEVEL%'=='1' echo Please search manually or Confirm with Authorities
:CONT
del "test.txt"
PAUSE
EXIT

:OPEN
set /p extract=<"test.txt"
start "" "%extract%"
echo FILE FOUND
echo Please wait while the file opens.
GOTO CONT