Page 1 of 1

Recursive find with spaces in filenames

Posted: 05 Jun 2009 11:05
by smbUK
Apologies if this is a real noob question, but I havent been able to find anything elsewhere.

All I'm trying to do is to have a for statement (or something similar so that I can call another function) that returns all the *.bat files recursively from the current directory, ensuring that filenames with spaces are handled properly (example should echo full path and filename including spaces) i.e.

for each file of type *.bat from current directory, "dir /B [filename]" the found file. This obviously isnt what I'm trying to do, just proves the spaces are handled correctly.

Thanks in advance

Posted: 05 Jun 2009 13:49
by avery_larry
I don't fully understand your problem.


dir /b *.bat

For handling spaces, make sure you but the filename/pathname in quotes


for /f %%a in ('dir /b *.bat') do call otherscript.cmd "%%a"