如何通过设计避开'Windows目录问题? [英] How to get around a 'by design' issue with Windows dir?

查看:53
本文介绍了如何通过设计避开'Windows目录问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

dir/b会生成一个漂亮的仅文件列表

dir/x生成详细列表(日期,时间,大小,长名,短名)

但是,如果将两者(即dir/b/x)组合在一起,则/x开关将被忽略.页的这种行为是设计使然.

因此,如果您要求一个仅包含文件短名称的简单列表,雷德蒙德(Microsoft)表示,将其提供给您是违反天堂规则的.

如何解决这个按设计"问题?

非常感谢

p.s.这是为了帮助我实现 this中解释的内容问题.五个善良的朋友对我非常感激的人发布了答案,但是没有答案帮助我得到了我想要的东西.

解决方案

尝试一下:

 用于/f"usebackq delims ="(dir/b`)中的%X做@echo%〜nsxX 

或者,如果您需要标准路径名:

对于/f"usebackq delims ="%dir in(`dir/b`)的

 执行@echo%〜fsX 

有关更多信息,请参见以获得帮助:

<代码>

请注意,如果您在批处理文件中使用这些命令,则需要将符号加倍.例如:

对于/f"usebackq delims ="(dir/b`)中的%% X的

  

dir /b produces a nice file-only list

dir /x produces a detailed listing (date, time, size, longname, shortname)

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.

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?

many thanks in advance

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.

解决方案

Try this:

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 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

这篇关于如何通过设计避开&amp;#39;Windows目录问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆