#1 16 Oct 2017 19:31

imogene
Member
Registered: 08 Oct 2017
Posts: 5

more efficient method of FOR recursing sub-dir in NT4.0/Win2000

I am looking for a more efficient method of recursing sub-directories with the FOR command, since FOR /R is not available in NT4/W2000.

I am using the following to process 25,000+ files in ~2500 sub-directories:

1- determine next sub-dir to process, FOR /F
2- move sub-dir to process folder
3- determine next filename in sub-dir to process until no more files, FOR /F
repeat until no more sub-dirs.

------
:: get sub-dir
FOR /F "delims=" %%i IN ('dir /b *.*') DO SET sub_dir=%%i
IF "%sub_dir%"=="" goto end
------

------
:: get filename
FOR /F "delims=" %%h IN ('dir /b %temp_dir%\%sub_dir%\*.*') DO SET filename=%%h
IF "%filename%"=="" goto process_done
------

It is a long process, as the DIR command must scroll through 2500 sub-directories before finding the next sub-dir to process.

Offline

#2 16 Oct 2017 21:03

Shadow Thief
Member
Registered: 12 Jul 2012
Posts: 169

Re: more efficient method of FOR recursing sub-dir in NT4.0/Win2000

I don't have a Windows 2000 VM available, but did dir have the /S option yet?

Offline

#3 16 Oct 2017 23:04

imogene
Member
Registered: 08 Oct 2017
Posts: 5

Re: more efficient method of FOR recursing sub-dir in NT4.0/Win2000

Yes, dir /s is available in NT4/W2000.

/s:  displays files in specified directory and all sub-dirs.

Offline

#4 17 Oct 2017 04:48

Shadow Thief
Member
Registered: 12 Jul 2012
Posts: 169

Re: more efficient method of FOR recursing sub-dir in NT4.0/Win2000

Well there you go.

for /f "delims=" %%I in ('dir /b /s *.*') do call :process_file %%I

Offline

#5 17 Oct 2017 16:25

imogene
Member
Registered: 08 Oct 2017
Posts: 5

Re: more efficient method of FOR recursing sub-dir in NT4.0/Win2000

That is interesting, thank you.   I will see if I can get that to work for me.

Offline

Board footer

Powered by FluxBB