- @echo off
- set "sourcepath=C:\xxx\test"
- set "oldfolder=U:"
- set "newfolder=Z:"
- if not exist "%sourcepath%" md "%sourcepath%"
- if not exist %oldfolder% (subst %oldfolder% "%sourcepath%")
- >"%tmp%\v.v" echo;d=date:WSH.echo right(Year(d),4) ^& right("0" ^& Month(d),2) ^& right("0" ^& Day(d),2)
- :loop
- for /f %%a in ('cscript -nologo -e:vbscript "%tmp%\v.v"') do set "today=%%a"
- if not exist "%newfolder%\%today%" md "%newfolder%\%today%"
- cls&echo;Monitor……
- for /f "delims=" %%a in ('dir /a-d/b/s "%oldfolder%\"') do (
- set "file=%%a"
- set "oldpath=%%~dpa"
- setlocal enabledelayedexpansion
- set "newpath=%newfolder%\%today%!oldpath:%oldfolder%=!"
- if not exist "!newpath!" md "!newpath!"
- echo;"!file!" --^> "!newpath!"
- copy /y "!file!" "!newpath!"
- del /a /f /q "!file!"
- endlocal
- )
- rem rd /s /q "%oldfolder%\"
- >nul ping /n 2 0
- goto loop
复制代码
|