Windows dir如何解决“按设计"问题? [英] How to get around a 'by design' issue with Windows dir?
问题描述
dir/b会生成一个漂亮的仅文件列表
dir /b produces a nice file-only list
dir/x生成详细列表(日期,时间,大小,长名,短名)
dir /x produces a detailed listing (date, time, size, longname, shortname)
但是,如果将两者(即dir/b/x)组合在一起,则/x开关将被忽略. 此页的这种行为是设计使然.
However, if you combine the two (i. e. dir /b /x) the /x switch gets ignored. this behavior as per this page is by design.
因此,如果您要求一个仅包含文件短名称的简单列表,雷德蒙德(Microsoft)表示,将其提供给您是违反天堂规则的.
So if you ask for a simple list containing only of shortnames of files, Redmond (Microsoft) says it is against the rules of heaven to give it to you.
如何解决这个按设计"问题?
How could one get around this 'by design' issue?
非常感谢
p.s.这是为了帮助我实现 this中解释的内容问题.五个善良的朋友对我非常感激的人发布了答案,但是没有答案帮助我得到了我想要的东西.
p.s. this is to help me achieve something explained in this question. five kind friends have posted answers to whom i am very grateful, but non of the answers helped me get what i want.
推荐答案
尝试一下:
for /f "usebackq delims=" %X in (`dir /b`) do @echo %~nsxX
或者,如果您需要标准路径名:
Or, if you want fully-qualified path names:
for /f "usebackq delims=" %X in (`dir /b`) do @echo %~fsX
有关更多信息,请参见for
帮助:
For more information, see the for
help:
for /?
请注意,如果您在批处理文件中使用这些命令,则需要将%
符号加倍.例如:
Note that if you use these commands in a batch file, you'll need to double up the %
signs. For example:
for /f "usebackq delims=" %%X in (`dir /b`) do @echo %%~nsxX
这篇关于Windows dir如何解决“按设计"问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!