specify the sort order in "copy /b *.dat foo" in Windows cmd

Solution 1:

This will concatenate the files (even the ones with spaces) in reverse order:

C:\> for /f "tokens=*" %i in ('dir /a-d /o-n /b c:\some_dir\*') do @type %i >> c:\another_dir\dest.dat

If there are only a few files, you can list them explicitly:

C:\> copy /b c.dat+a.dat+b.dat dest.dat

Something like this might work in some situations:

C:\> copy /b file*.dat+foo.dat+bar*.dat dest.dat