How to sort multiple FASTA files based on their content?
That's quite easy with cmd:
@echo off
for /l %%i in (1,1,8) do (
  for /f &quot;delims=&quot; %%f in ('findstr  /mc:&quot; segment %%i &quot; *.txt') do (
    ECHO move &quot;%%f&quot; &quot;segment %%i\&quot;
  )
)

findstr /mc:&quot;string&quot; *.txt searches each matching file for the string and outputs the filename, if the string was found. The for /f loop around catches those filenames, so you are able to move them. The for /l loop just iterates from 1 to 8.
See for /? and findstr /? for more information about those commands.
You probably want to adapt the filemask *.txt to your needs.
Note: I &quot;disarmed&quot; the move command for troubleshooting. Remove the ECHO when you are sure it does what you want.