How to enclose each line resulted from command line dir/b /s /c *.txt inside quotations
dir/b /s /c *.txt
The command displays all the txt file available in the directory. I need the path of each file inside double quotes
You can use the for command, for example, this outputs all the requested files into a file named x.x:
(for /f "delims=" %f in ('dir /b /s /c *.txt') do @echo "%f") > x.x
Note that if you use this in a batch file (ie. not directly from the command prompt), you have to escape the % char as %%, ie:
(for /f "delims=" %%f in ('dir /b /s /c *.txt') do @echo "%%f") > x.x
Also, if you have PowerShell on the computer (server Windows do from version 2k3 or so, I'm not sure; you can install it of course), that's an even more powerful command-line tool - it basically gives you a fully fledged .NET language to do even complex administration tasks. However, I tend to use simple tools for simple tasks, and this is still a simple task :)
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