Board logo

标题: [文件操作] 批处理无法创建文件夹的问题 [打印本页]

作者: 41348934    时间: 2017-3-22 11:03     标题: 批处理无法创建文件夹的问题

本帖最后由 pcl_test 于 2017-3-22 11:18 编辑
  1. @echo off&setlocal enabledelayedexpansion
  2. for /f "tokens=2 delims==" %%a in ('wmic path win32_operatingsystem get LocalDateTime /value ^| findstr "="') do set "strDate=%%a"
  3. set today=%strDate:~0,4%%strDate:~4,2%%strDate:~6,2%
  4. set "a=D:\test\test"
  5. if exist "%a%\%today%\" (echo;Directory already exists!) else md "%a%\%today%\"
  6. pause
复制代码
  1. @echo off&setlocal enabledelayedexpansion
  2. for /f "tokens=2 delims==" %%a in ('wmic path win32_operatingsystem get LocalDateTime /value ^| findstr "="') do set "strDate=%%a"
  3. set today=%strDate:~0,4%%strDate:~4,2%%strDate:~6,2%
  4. set "a=D:\ftptemp\jp24backsnd"
  5. if exist "%a%\%today%\"(echo;Directory already exists!) else md "%a%\%today%\"
  6. pause
复制代码
两段代码除了路径不同没区别啊  为什么第2个就是不成功呢
作者: pcl_test    时间: 2017-3-22 11:17

if exist "%a%\%today%\" (echo;Directory already exists!) else md "%a%\%today%\"

少空格,严谨点吧,学点基础吧
作者: ShowCode    时间: 2017-3-22 11:40

把 @echo off 删掉再执行,报错信息发出来看看。
作者: 41348934    时间: 2017-3-22 12:59

回复 2# pcl_test

还真是空格  谢谢版主
作者: 41348934    时间: 2017-3-22 12:59

回复 3# ShowCode

解决了 谢谢你




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2