I'm trying to figure out how to match folders with a dot in the file name (eg, ".svn") in a Windows batch script.
Here's the basic script:
setlocal
pushd c:\myDir
@echo off
FOR /D /r %%G in ("*\.whatever") DO (
echo %%G
REM do stuff
)
@echo on
popd
endlocal
This works just fine for most folder names (eg, "*bin"
), but I can't figure out the method to specify a folder with the dot. "*.whatever"
and "*\\.whatever"
return no results. I'm guessing I'm missing some escape character or something equally simple, but I haven't been able to find any documentation on it.
(Before anyone asks, no I'm not trying to recursively delete subversion folders; "*.svn"
is just an example.)
Maybe I am missing something, but as you say it seems simple
for /r /d %%a in (.*) do echo %%~fa
But if the folders are hidden, the normal for
will not be able to see them, so we need to execute a dir
command an process its output with a for /f
for /f "delims=" %%a in ('dir /ad /s /b .*') do echo %%~fa
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.