# Move command while specifying # of files to be moved?



## broncobuddha (Mar 11, 2010)

Trying to automate a process here at work.

Folder 1 has 90k something .txt files that need to be moved into folder 2 so, another program can grab that data and import it elsewhere.

The problem is, the program can only handle so many files at a time or it crashes. I mean like 47 files is the max.

So, I've been searching for a way to move (not copy) only 47 files at a time. This would run every 15 minutes or so, so, I'm guessing it'd be a loop.

As far as I can tell, it doesn't matter what order they're in as it's historical (finite) data that's being moved.

Any help would be greatly appreciated.

Sorry, this can either be for XP or server 2003.


----------



## Squashman (Apr 4, 2003)

You will need to use Task Scheduler to run the task every 15 minutes.

```
@Echo Off & SetLocal EnableExtensions EnableDelayedExpansion
:: Where your files are located.
Set _Base=C:\Test Dir1
:: Where they need to be copied too.
set _Output=C:\Test Dir2
PushD "%_Base%"
set _count=0
For /F "Tokens=* Delims=" %%A In ('Dir /A-D /B /OD') Do (
	move "%%A" "%_Output%"
	Set /A _count+=1
	IF !_count! EQU 47 GOTO END
)
:END
PopD
```


----------



## broncobuddha (Mar 11, 2010)

Thanks, Squashman.

When I run it, I get *EQ was unexpected at this time*.

Note, I'm running this on XP.


----------



## Squashman (Apr 4, 2003)

Oops. Forgot the the U.
IF !_count! EQU 47 GOTO END


----------



## broncobuddha (Mar 11, 2010)

Awesome, that worked!

Thanks!


----------

