Recursive find with spaces in filenames

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
smbUK
Posts: 1
Joined: 05 Jun 2009 10:47

Recursive find with spaces in filenames

#1 Post by smbUK » 05 Jun 2009 11:05

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

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#2 Post by avery_larry » 05 Jun 2009 13:49

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"

Post Reply