Originally posted by zw19750516 at 2008-5-28 04:17 PM:
我以为楼主是要移走所有的,所以我加了/s,如不要移走子目录中的去掉/s就可以了。
Last edited by zw19750516 on 2008-5-28 at 04:23 PM ]
@echo off&setlocal enabledelayedexpansion
set str=.td .cfg
for /f "delims=" %%i in ('dir /a-d /b D:\batch\test\*.*') do (
set "flag="
for %%a in (%str%) do if "%%a"=="%%~xi" set flag=A
if not defined flag move /y "%%i" D:\batch\test\temp\
)
pause
为什么我运行这个会出错?错误信息是:
D:\batch>moveFile
The system cannot find the file specified.
The system cannot find the file specified.
Press any key to continue . . .
另外'dir /a-d /s也会出错:
D:\batch>moveFile
The system cannot find the file specified.
The system cannot find the file specified.
The filename, directory name, or volume label syntax is incorrect.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the file specified.
The filename, directory name, or volume label syntax is incorrect.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the file specified.
The filename, directory name, or volume label syntax is incorrect.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the file specified.
" Total Files Listed:" is not a recognized device.
" Total Files Listed:" is not a recognized device.
The filename, directory name, or volume label syntax is incorrect.
The system cannot find the file specified.
The system cannot find the file specified.
Press any key to continue . . .
给解析下,谢谢
Originally posted by zw19750516 at 2008-5-28 05:24 PM:
D:\batch\test\temp\这个路径是不是实际存在的啊。
存在的呢。我运行
@echo off&setlocal enabledelayedexpansion
set str=.td .cfg
for /f "delims=" %%i in ('dir/b/a-d "D:\batch\test\*.*"') do (
set "flag="
for %%a in (%str%) do if "%%a"=="%%~xi" set flag=A
if not defined flag move /y "%%i" D:\batch\test\temp\
)
pause
是可以的!非常奇怪,去掉/s就不行了
-------------------------------------------------------------
另外,我测试
for /f "delims=" %%i in ('dir/b/a-d "D:\batch\test\*.*"') do (
echo %%~nxi
)
是能遍历test底下的文件的呢,很奇怪哦