![](/img/trans.png)
[英]Copy multiple files from different folder with same filename to one common folder using windows batch file
[英]Intelligent folder in windows using batch file to copy files
如果文件的大小不再变化(完全处理),我想将文件从dir1移动到dir2。 可能的参与方式是询问size0(0s)和size10(10s),如果size0 = size10,则将文件从dir1移动到dir2。
如何在Windows XP的命令行中执行此操作?
尝试这个:
@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
像这样的东西可能会起作用:
@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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.