1

I have some files in C:\TEST directory with custom naming convention as following

  • 102_File1.txt
  • 1_File1.txt
  • 10_File1.txt
  • 2_File1.txt
  • 3_File1.txt
  • 202_File1.txt

I want to concatenate the content of every *.txt file of C:\Test directory into single file.

I have code snippet of batch file like this : FOR /r "C:\Test" %%F IN (*.txt) DO ( process content of the file)

BUT using above code snippet, it concatenates all the files in normal sorting order as follows

  • 102_File1.txt
  • 10_File1.txt
  • 1_File1.txt
  • 203_File1.txt
  • 2_File1.txt
  • 3_File1.txt

I want to concatenate all files in a natural numbering order so that newly created file with have concatenated content in following sequence only

  • 1_File1.txt
  • 2_File1.txt
  • 3_File1.txt
  • 10_File1.txt
  • 102_File1.txt
  • 202_File1.txt

How can I achieve this using batch script?

Umesh Kadam
  • 843
  • 2
  • 7
  • 14

0 Answers0