Windows中的智能文件夹使用批处理文件来复制文件

时间:2013-07-24 17:13:36

标签: windows batch-file windows-xp directory copy-paste

如果文件的大小不再变化(完全处理),我想将文件从dir1移动到dir2。可能参加的是询问size0(0s)和size10(10s),如果size0 = size10,则将文件从dir1移动到dir2。

如何在windows xp的命令行中执行此操作?

2 个答案:

答案 0 :(得分:2)

试试这个:

@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

答案 1 :(得分:0)

这样的事可能有用:

@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