>This didn't work for me. It took 32 s. to create a file and the returned files are in DOS like way (short names).
I have a similar directory, with 27400 small images. First I thought you had foxpro.pif which uses command.com instead of cmd.exe, so I invoked each and ran dir >dir.txt. The time in both cases was below a second.
The format of the text was like this (with just plain DIR, no switches):
22.01.2005 11:17 39,749 CP701760.jpg
22.01.2005 11:17 35,626 CP701761.jpg
09.03.2004 12:37 23,487 No-Show-Image.jpg
07.02.2006 13:27 60 nocopy.BAK
07.02.2006 13:29 284 nocopy.bat
Maybe you could use shell_execute to run the command? Just create a .bat file and run that. Shouldn't take that long. Even with my disk being recently defragmented, the difference shouldn't be so large.