要将d:\TestLog下除了当日的文件夹移动到d:\backup
脚本如下
@echo off
mode con lines=30 cols=60
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
cd /d "%~dp0"
set logRoot=d:\TestLog
set D=%date:~0,4%%date:~5,2%%date:~8,2%
d:
cd \
md backup
cd TestLog
for /f "" %%a in ('dir /b') do (
for %%I in (AT,CAT) do (
if exist %logRoot%\%%a\%%I (
for /d %%c in (%logRoot%\%%a\%%I\*) do (
echo %%c
if "%%c" == "%logRoot%\%%a\%%I\%D%" (echo file not loading) else (move %%c d:\backup\ )
)
)
)
)
出现错误:
错误原因:目标文件夹已存在同名的要移动的文件夹