I'm trying to do some things during the pre-build phase of a visual studio project. Specifically, I'm trying to execute some commands on all *.resx files within the project. Here is what I have but it doesn't work when the files/directory path have a space in them. How do I get around these spaces?
for /f %%a in ('dir /B /S *.resx') do echo "%%a"
Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. ( <set> ) Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.
Press the windows key + r (this opens the "run" window) Type: cmd into the text input and press enter (or click ok) Change to the directory that contains the batch file, e.g: cd c:\scripts\foo. Execute the batch file by typing it's name and pressing enter, e.g: somename.
You know that for
can also run recursively over directories?
for /r %%x in (*.resx) do echo "%%x"
Much easier than fiddling with delimiters and saves you from running dir
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With