Home > Software design >  Windows command line globbing with full path
Windows command line globbing with full path

Time:11-03

I know that I can do basic globbing that prints me the full path like so: for %f in (pattern) do @echo %~dpnxf

However, if I do c:\dev>for %f in ("src/*.c") do @echo %~dpnxf, where with the pattern I'm searching within a subdirectory, instead of getting c:\dev\src\main.c I'm only getting c:\dev\main.c as a result. It basically doesn't include the any subdirectory in the p modifier.

I'm now stuck on that for longer than I'd like to admit... Is there a way to fix this?

CodePudding user response:

  • cd /D %windir%\..&for %f in ("windows\exp*.exe") do @echo %~dpnxf works.
  • cd /D %windir%\..&for %f in ("windows/exp*.exe") do @echo %~dpnxf does not work.

I guess / is a problem. Just use the real path separator on Windows which is \.

  • Related