【问题标题】:How to use the list files in a given directory via batch file without showing the full path?如何通过批处理文件使用给定目录中的列表文件而不显示完整路径?
【发布时间】:2013-03-27 21:17:42
【问题描述】:

我已经到处搜索了这个,所以我希望它还没有被问到,但是我有一个批处理文件,如果你愿意,用户可以在其中编写他/她自己的“脚本”。第一次运行批处理文件时,它将在 %appdata%\Mellow\Mango\scripts 下创建一个目录,这些脚本将只是 .txt 文件。总之……

我正在尝试使用dir /b /s *.txt 向用户列出“脚本”,输出为C:\Users\Tate\AppData\Roaming\Mellow\Mango\scripts\template.txt

我的问题是,对不起,如果我之前跑题了,如何只显示 template.txt 而不是完整的文件路径。我只是想列出脚本文件夹中包含的所有 .txt 文件。提前致谢!

电流输出:

C:\Users\Tate\AppData\Roaming\Mellow\Mango\scripts\template.txt
C:\Users\Tate\AppData\Roaming\Mellow\Mango\scripts\another_script.txt

期望的输出:

template.txt
another_script.txt

【问题讨论】:

    标签: windows batch-file path dir


    【解决方案1】:

    只需删除 /s

    dir /b *.txt

    应该这样做:)

    【讨论】:

    • 感谢您的快速回答!我本可以发誓我之前尝试过,但我想我只尝试删除 /b 并尝试添加 /x 等。现在完美运行! (:编辑:我可能应该查一下 /letters 的含义,因为我现在想想啊哈。
    • 发生在我们最好的人身上。很高兴我能帮上忙。
    猜你喜欢
    • 2011-01-02
    • 1970-01-01
    • 2012-01-21
    • 2012-07-12
    • 1970-01-01
    • 1970-01-01
    • 2016-08-16
    • 1970-01-01
    • 2018-03-22
    相关资源
    最近更新 更多