You can use the for loop:
for %%x in (*.dat) do mycommand "%%x"
This will run the command once for each file. If you want to fill them out, you need to do some more work:
setlocal enabledelayedexpansion set Count=0 set List= for %%x in (*.dat) do ( set List=!List! "%%x" set /a Count+=1 if !Count! GEQ 50 ( mycommand !List! set List= set Count=0 ) )
This will transfer 50 files at a time to the command. You can customize this number if you want. The problem is that you have thousands of files in the folder, then you cannot just list them all on one command line (because there is a limit on the maximum length of the command line), so you need to process them in pieces.
source share