本帖最后由 zaqmlp 于 2022-5-27 21:13 编辑
- @echo off&cd /d "%~dp0"&mode con lines=5000&rem bat存为编码ANSI
-
- set "nas_folder=\\nas_ip\zipfolder"
- set sleep=120
- set "run_bat=.\123.bat"
-
- :loop
- set "local_folder="
- for %%a in (
- ".\aaa\bbb-V15\ccc"
- ".\aaa\bbb-V14\ccc"
- ) do (
- set "count="
- if exist "%%~a" (
- for /f "delims=" %%b in ('dir /a-dh/b "%%~a\" 2^>nul') do del /a /f /q "%%~a\%%~nxb"
- for /f "delims=" %%b in ('dir /a-d-h/b "%%~a\" 2^>nul') do set /a count+=1
- if not defined count (
- set "local_folder=%%~a"
- goto :movefile
- )
- ) else (echo;"%%~a" path error or not existed)
-
- )
- if not defined local_folder (
- echo;can not find any empty local folders
- goto :break
- )
-
- :movefile
- echo;local_folder="%local_folder%"
-
- set "ver="
- for /f "delims=" %%a in ("%local_folder%") do set "fd=%%~dpa"
- for /f "delims=" %%a in ("%fd:~,-1%") do (
- for /f "tokens=1* delims=-" %%b in ("%%~nxa") do set "ver=%%c"
- )
- if not defined ver (
- echo;can not get version number
- goto :break
- )
- echo;ver="%ver%"
-
- echo;"%nas_folder%\*-%ver%.zip" is finding……
- for /f "delims=" %%a in ('dir /a-d/b/od/tw "%nas_folder%\*-%ver%.zip"') do (
- echo;"%nas_folder%\%%~nxa" --^> "%local_folder%\"
- move "%nas_folder%\%%~nxa" "%local_folder%\"
- if exist "%run_bat%" (start "" "%run_bat%") else (echo;"%run_bat%" not found)
- goto :break
- )
-
- :break
- timeout /t %sleep% /nobreak
- goto loop
复制代码
|