Computing.Net > Forums > Programming > Moving multiple files using batch

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Moving multiple files using batch

Reply to Message Icon

Name: trackero
Date: January 2, 2009 at 13:59:28 Pacific
OS: Windows XP
CPU/Ram: Intel Xion
Product: Dell / 1950
Subcategory: General
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: January 2, 2009 at 14:35:32 Pacific
Reply:

@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


0

Response Number 2
Name: IVO
Date: January 3, 2009 at 03:11:12 Pacific
Reply:

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


0

Response Number 3
Name: trackero
Date: January 3, 2009 at 14:15:43 Pacific
Reply:

It worked like a charm, thanks for the help.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Moving multiple files using batch

rename multiple file whit batch fil www.computing.net/answers/programming/rename-multiple-file-whit-batch-fil/9028.html

Need help in creating multiple files using ba www.computing.net/answers/programming/need-help-in-creating-multiple-files-using-ba/19001.html

Editing a Hex file using a Batch script www.computing.net/answers/programming/editing-a-hex-file-using-a-batch-script/19381.html