Search code examples
windowscmdwindows-console

How to put result of directory search in variable?


I want to use dir command to search files (there will be only one file that match) and after that I want to put result of search (found file) in variable.

Reason for doing thinks like this is pretty simple. I want to avoid to put full directory after cd.

Please help me out.


Solution

  • Your question isn't clear.

    for /f "delims=" %A in ('dir c:\windows\*.ini') do Echo %A