How can I output a list of filenames surrounded by quotation marks?
You can use FOR /F
to run the DIR
command and surround the output with quotes:
This is from the prompt
for /f "delims=" %A in ('dir /b /od *.png') do @echo "%A"
In a batch script, you would double the percent signs, so %A
becomes %%A
in both places.
A way using PowerShell:
(dir *.png | sort creationTime | % {"`"$($_.name)`""}) >>files.txt
- Filter
*.png
usingGet-ChildItem
. - Sort them by
CreationTime
. - Add double quotes to their names using
Foreach
loop - Then write them to
files.txt
using operator.