标题: 红包20-批处理实现监测某路径下变量目录内的几个文件名同时存在则执行指令 [打印本页]
作者: 252007313 时间: 2018-8-8 10:06 标题: 红包20-批处理实现监测某路径下变量目录内的几个文件名同时存在则执行指令
红包20-bat批处理实现监测某路径下变量目录内的几个文件名同时存在则执行指令。
已有代码CPU占用率太高,求优化!
wx:252007313
@echo off
set Dir=C:\Release\ftp\up4
set Files=1.jpg,2.jpg,3.jpg,4.jpg
cd /d "%Dir%"
oop
set "Num=0" & set "AllNum=" & set "Old="
for /f "delims=" %%a in ('dir /ad/o-d/b') do set "Old=%%~a"
if defined Old (
for %%a in (%Files%) do (
set /a AllNum+=1
if exist "%Old%\%%~a" set /a Num+=1
)
)
if not defined AllNum goto Loop
if not %Num% equ %AllNum% goto Loop
cd C:\Release
C:\Release\ftp\bat\%Old%.bat
作者: digger 时间: 2018-8-8 10:59
本帖最后由 digger 于 2018-8-8 12:43 编辑
回复 1# 252007313 - @echo off&setlocal enabledelayedexpansion
- set Dir=C:\Release\ftp\up4
- set Files=1.jpg,2.jpg,3.jpg,4.jpg
- set name=!Files:,=^
-
- !
- cd /d "%Dir%"
- :Loop
-
- rem 延时3S
- choice /t 3 /d y /n >nul
-
- set "Num=0" & set "AllNum=" & set "Old="
- for /f "delims=" %%a in ('dir /ad/o-d/b') do set "Old=%%~a"
- if defined Old (
- for /f "delims=" %%i in ("!name!") do (
- set /a AllNum+=1
- if exist "!Old!\%%~i" set /a Num+=1
- )
-
- )
- if not defined AllNum goto Loop
- if not !Num! equ !AllNum! goto Loop
-
- cd C:\Release
- C:\Release\ftp\bat\!Old!.bat
- pause
复制代码
作者: 252007313 时间: 2018-8-8 13:04
感谢 依梦琴瑶 完美解决 关贴声明
@echo o ff
set Dir=C:\Release\ftp\up4
set Files=1.jpg,2.jpg,3.jpg,4.jpg
oop
cd /d "%Dir%"
set "Old="
for /f "delims=" %%a in ('dir /ad/o-d/b') do set "Old=%%~a"
if not defined Old goto Wait
for %%a in (%Files%) do (
if not exist "%Old%\%%~a" (
goto Wait
)
)
goto MoveFiles
:Wait
timeout /t 2 /nobreak >nul
goto Loop
:MoveFiles
cd C:\Release
C:\Release\ftp\bat\%Old%.bat
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |