【问题标题】:Batch- Does MKDIR skip over a folder if it already exists and move onto the next one?批处理 - 如果文件夹已存在,MKDIR 是否会跳过该文件夹并移至下一个文件夹?
【发布时间】:2015-03-04 19:26:53
【问题描述】:

我正在尝试创建一个批处理文件,该文件会在现有目录中创建一系列文件夹。 如果目录的一部分已经存在,MKDIR 会跳过那个目录并继续向下目录还是会覆盖它?

这里有一个示例代码:

mkdir %cdriveletter%\Steam\SteamApps\common\Counter-Strike Source\cstrike\custom\my_custom_skins\

在该代码中,我只想创建 MyCustomSkins 文件夹,但它必须位于该目录中。我不希望它覆盖它之前的东西。

这就够了吗?

【问题讨论】:

  • mkdir 从不删除任何“东西”

标签: batch-file cmd mkdir steam


【解决方案1】:

mkdir 命令将创建指定路径中不存在的所有文件夹,除非禁用扩展 (setLocal enableExtensions) - 无论如何,它不会破坏目录并创建具有相同名称的新目录。

mkdir /?-

...

MKDIR creates any intermediate directories in the path, if needed.
For example, assume \a does not exist then:

    mkdir \a\b\c\d

is the same as:

    mkdir \a
    chdir \a
    mkdir b
    chdir b
    mkdir c
    chdir c
    mkdir d

which is what you would have to type if extensions were disabled.

您可能还应该用引号将您的路径括起来。

注意:您可以自己测试,方法是创建一些“测试”目录并编写类似的命令。

【讨论】:

  • “如果扩展程序被禁用,您必须输入的内容” - 鉴于此,您可能需要澄清您的第一句话。
猜你喜欢
  • 2021-08-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-13
  • 2023-02-01
  • 2010-11-02
  • 1970-01-01
相关资源
最近更新 更多