简体   繁体   中英

Intelligent folder in windows using batch file to copy files

I would like to move a file from dir1 to dir2 if its size is not changing anymore (fully processed). A possible attend would be to ask size0(at 0s) and size10(at 10s) and if size0=size10 than move file from dir1 to dir2.

How to do it in command line on windows xp?

try this:

@ECHO OFF &SETLOCAL
CD /d dir1
:loop
FOR %%a IN (file) DO SET "size=%%~za"
PING -n 10 localhost >NUL
FOR %%a IN (file) DO IF %%~za equ %size% (move "%%~a" dir2) ELSE GOTO :loop

Something like this might work:

@echo off

setlocal

set "file=C:\path\to\your.file"
set "destination=D:\some\folder"

:loop
call :GetSize "%file%" s1
call :Sleep 10
call :GetSize "%file%" s2
if %s1% neq %s2% goto loop

call :MoveUnlessExists "%file%"

goto :eof

:GetSize
set "%~2=%~z1"
goto :eof

:Sleep
set /a "n=%1+1"
ping -n %n% 127.0.0.1 >nul
goto :eof

:MoveUnlessExists
if not exist "%destination%\%~nx1" move "%~f1" "%destination%\"
goto :eof

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM