【发布时间】:2016-03-04 13:23:30
【问题描述】:
我使用脚本扫描整个用户的驱动器 C 以查找特定文件,然后将结果记录在网络上的 txt 中。它就像一个魅力。
这是脚本:
@echo off
pushd C:\
dir /s /a-d "setup.txt" /s "setup2.txt" >nul && (goto printresult) || (goto notfound)
:printresult
dir /s /a-d setup.txt /s setup2.txt >>"\\servidor\pastadelogs\FOUND_%computername%.txt
popd
exit
:notfound
echo "Este PC não possui os arquivos" >>"\\servidor\pastadelogs\NOTFOUND_%computername%.txt
popd
exit
现在我需要对其进行改进,使其也能在 USB 驱动器内进行扫描。我已经有一个可以给我 USB 字母的代码:
@echo off
for /F "usebackq tokens=1,2,3,4 " %%i in (`wmic logicaldisk get caption^,description^,drivetype 2^>NUL`) do (
if %%l equ 2 (
echo %%i is a drive letter
)
)
我的两个问题是:
- 可以一起使用吗?
- 如果插入了多个 USB 怎么办?它将如何运作?我可以为每个驱动器号结果设置 1 个变量吗?
最好的问候
【问题讨论】:
标签: batch-file