批处理和cmd.exe

时间:2016-08-02 10:46:31

标签: windows batch-file cmd

我试图在所有驱动器中搜索文件名。单独使用dir命令时一切顺利:

C:\>dir /s C:\*blabla*
 Volume in drive C has no label.
 Volume Serial Number is 2AB1-3FBD

  Directory of C:\Users\Administrator\Desktop

 02/08/2016  11:21                 0 blabla.txt
           1 File(s)              0 bytes

 Total Files Listed:
           1 File(s)              0 bytes
           0 Dir(s)  28?369?825?792 bytes free

但是在循环中使用它时会失败:

FOR /F "skip=1 delims=" %x in ('wmic logicaldisk get caption') do dir /s %x*blabla*

*blabla* Administrator\Desktop>dir /s A:       
The device is not ready.

*blabla* Administrator\Desktop>dir /s C:       
Volume in drive C has no label.

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

感谢您的所有帮助,以及对其他脚本的好主意。

我一直在寻找答案:

C:\>FOR /F "skip=1 delims= " %x in ('wmic logicaldisk get caption') do @where /R %x *blabla* 2>NULL
C:\Users\Administrator\Desktop\blabla.txt