@echo off
set "var=string"
set "today=%date:~10,4%-%date:~7,2%-%date:~4,2%"
set "path_backup=\\SGSINWPDFS01v\SG\OTHERS\IT\OTHERS\WORKSTATIONS\SCHEDULE"
set "path_sourcepst01=AppData\Local\Microsoft\Outlook"
set "path_sourcepst02=Desktop"
set "path_sourcepst03=My Documents\PST"
set "path_sourcepst04=My Documents\Outlook"
set "path_sourcepst05=My Documents\Outlook Files"
mkdir "%path_backup%\%username%\%today%"
mkdir "%path_backup%\%username%\%today%\PST"
mkdir "%path_backup%\%username%\%today%\PST\%path_sourcepst01%"
mkdir "%path_backup%\%username%\%today%\PST\%path_sourcepst02%"
mkdir "%path_backup%\%username%\%today%\PST\%path_sourcepst03%"
mkdir "%path_backup%\%username%\%today%\PST\%path_sourcepst04%"
mkdir "%path_backup%\%username%\%today%\PST\%path_sourcepst05%"
我对脚本进行了如下修改。
我仍然系统仍然无法在sourcepst01、03、04和05创建文件夹。
sourcepst02工作正常。
看来我无法理解MKDIR的全部路径,系统感到困惑,必须一步一步地做。
我在这里想念什么吗?
最佳答案
添加行:
setlocal enableextensions
刚好在批处理文件的
@echo off
行之后。这将使mkdir
创建任何中间目录。help mkdir
的输出摘录:If Command Extensions are enabled MKDIR changes as follows:
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.
关于windows - Windows mkdir在单个命令中的多路径,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21224917/