给出一个像这样的for循环:
FOR /d /r "topDir" %%G in (*foo*) DO (
echo %%G
)
有没有办法排除某些文件夹?
如果文件夹的名称是 foobar ,请不要回复任何内容
但做回显,如果它包含foo并且只是 foobar
答案 0 :(得分:1)
PowerShell可用于选择目录并排除特定名称。
C:>TYPE t.bat
@echo off
DIR /A:D
FOR /F "usebackq tokens=*" %%d IN (`powershell.exe -NoProfile -Command "Get-ChildItem -Directory -Recurse -Filter '*foo*' -Exclude 'foobar' | ForEach-Object { $_.Name }"`) DO (
ECHO Selected directory is %%d
)
并执行示例。
C:>CALL t.bat
Volume in drive C has no label.
Volume Serial Number is 0E33-300C
Directory of C:\src\t\f
2017-12-31 16:46 <DIR> .
2017-12-31 16:46 <DIR> ..
2017-12-31 16:12 <DIR> barfoo
2017-12-31 16:12 <DIR> barfoochow
2017-12-31 16:12 <DIR> foo
2017-12-31 16:12 <DIR> foobar
2017-12-31 16:39 <DIR> zzz
0 File(s) 0 bytes
7 Dir(s) 792,276,733,952 bytes free
Selected directory is barfoo
Selected directory is barfoochow
Selected directory is foo
答案 1 :(得分:1)
您必须使用FirebaseUser.updatePhoneNumber()
循环来处理更复杂的命令:
for /f
另一种选择:
set "topDir=c:\topDir"
for /f "tokens=* delims=" %%a in (' dir /s /a:d "%topDir%\*foo*"^| find /v "foobar"') do (
echo %%a
)