Windows中的Linux mkdir -p等效于什么? [英] What is equivalent to Linux mkdir -p in Windows?

查看:436
本文介绍了Windows中的Linux mkdir -p等效于什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux中,mkdir -p创建一个文件夹树.

In Linux, mkdir -p creates a folder tree.

在Windows中创建文件夹树的等效选项是什么?有吗?

What is the equivalent option in Windows to create a folder tree? Is there any?

推荐答案

如果启用了命令扩展名,则Windows mkdir会自动执行此操作.它们几乎在我用过的每个盒子上,如果没有,则可以创建自己的脚本来实现:

The Windows mkdir does it automatically if command extensions are enabled. They are on just about every box I've ever used but, if they're not, you can create your own script to do it:

@echo off
setlocal enableextensions
md %1
endlocal

扩展:

命令扩展是cmd.exe的新增功能,它使您可以做更多的事情(以与批处理语言的早期版本稍作兼容为代价).

Command extensions are an added feature of cmd.exe which allows you to do so much more (at the cost of a little compatibility with earlier incarnations of the batch language).

Windows XP cmd.exe应该默认启用这些扩展,但是您可以配置您的机器,使其在默认情况下被禁用(使用"cmd /e:off"作为默认处理器).如果您这样做并且想要使用扩展名,则您的cmd文件必须具有setlocal才能将其重新打开.

Windows XP cmd.exe should have these extensions enabled by default but you can configure your box so that they're disabled by default (using "cmd /e:off" as the default processor). If you do that and want to use the extensions, your cmd files must have a setlocal to turn them back on.

上面的脚本可以称为md2.cmd,这样就可以确保可以使用"md2 a\b\c"创建多个目录级别,而不必担心扩展名是否已启用.

The script above could be called md2.cmd and then you would be guaranteed to be able to create multiple directory levels with "md2 a\b\c" without having to worry whether the extensions were enabled.

我编写的cmd脚本几乎每一个都始于:

Almost every one of the cmd scripts I write begins with:

setlocal enableextensions enabledelayedexpansion

以确保我尽可能地接近心爱的bash:-)

to ensure I get as close as possible to the behavior of my beloved bash :-)

这篇关于Windows中的Linux mkdir -p等效于什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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