Move Oldest Files First, 20 at a Time

March 5, 2010 at 14:41:12
Specs: Windows XP
Great site and appreciate everyone's help in advance,

I'm far from a DOS guru but could someone help me with how I can Move the oldest files in a directory first to another folder but only do a certain number of files at a time, for example 20 at a time?

I have an Oracle program parsing xml files but its unable to cope with a huge number of files at the same time (runs out of heap space) so want to move them in small numbers at a time, but the oldest first files first. A simple batch file would be great which I am happy to run as a scheduled task.

Thanks again for any help

See More: Move Oldest Files First, 20 at a Time

Report •

March 5, 2010 at 14:59:00
@echo off & setLocal EnableDELAYedeXpansion

set N=0

for /f "tokens=* delims= " %%a in ('dir/b/a-d/od') do (
set /a N+=1
if !N! gtr 20 goto :eof
move "%%a" somefold

Helping others achieve escape felicity


Report •

March 5, 2010 at 23:24:04
That's very very helpful. Thank you so much! I appreciate it.

Report •

Related Solutions

Ask Question