How to sort multiple FASTA files based on their content? So I have around 10,000 FASTA files of Influenza A virus. These files contains sequences of each of the 8 segments of the viral genome and I want to separate these files into different locations based on the content of these FASTA files.
In each FASTA file, first line has the segment number.
Eg.
&gt;KM368312.1 Influenza A virus (A/swine/Shandong/01/2009(H1N1)) segment 3 polymerase PA (PA) and PA-X protein (PA-X) genes, complete cds

Okay imagine you have 10,000 text files in one folder and there are 8 types of these text files based on the content of them. Eg. file1.txt has segment 1 written in it, file2.txt has segment 2 written in it upto segment 8. So I want to group the files containing segment 1 together in one folder, segment 2 in other folder together and so on.
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.