Moving multiple files using batch

Dell / 1950
January 2, 2009 at 13:59:28
Specs: Windows XP, Intel Xion
Hi folks!

Need some help here. I'm trying to sever thousand files to a directory in sequence of 100 at the time. So I want to copy 100 files first, then wait about 60 seconds to copy the next 100. This is what I got so far:

@echo off

setLocal EnableDelayedExpansion

:START
TIMEOUT 60
GO TO LOOP

:LOOP
FOR /F "tokens=* delims= " %%i IN ('dir /b ') DO (
set /a N+=1
move "%%i" D:/MYDIRECTORY
if !N! geq 100 GOTO START
)

::DONE

The first time it goes through fine for the first 100 files. But when it goes back to START, it starts copying one file every 60 seconds. Any help would be appreciated.

T.


See More: Moving multiple files using batch

Report •


#1
January 2, 2009 at 14:35:32
@echo off & setLocal EnableDelayedExpansion

:LOOP
set /A limit+=100
TIMEOUT 60

FOR %%i IN (*) DO (
set /A N+=1
move "%%i" D:/MYDIRECTORY
if !N! geq %limit% GOTO :LOOP
)

:DONE


Report •

#2
January 3, 2009 at 03:11:12
The following is an enhanced version of the native script without GOTOs and avoiding the initial 60 seconds delay.

@echo off & setlocal EnableDelayedExpansion

set LIM=100
for %%i in (*) do (
set /A N+=1
move "%%i" D:/MYDIRECTORY
if !N! geq !LIM! (TimeOut 60 & set /A LIM+=100)
)
:DONE


Report •

#3
January 3, 2009 at 14:15:43
It worked like a charm, thanks for the help.

Report •

Related Solutions


Ask Question