Parse out the julian day, file each filename into a dictionary for that month:
from datetime import datetime
import os.path
# months from 0 to 11
files_by_month = [[] for _ in range(12)]
for filename in filenames:
dt = datetime.strptime(os.path.splitext(filename)[0][1:], '%Y%j')
files_by_month[dt.month - 1].append(filename)
files_by_month
uses 0-based indexing to store a list per month; January is 0, etc.
This assumes that the filename always starts with one letter, followed by the year + julian year day, followed by the extension. If these assumptions are incorrect you need to provide more information on what sort of patterns there are in your filenames.
Demo for your sample filename:
>>> from datetime import datetime
>>> import os.path
>>> filename = 'A1998237.tif'
>>> datetime.strptime(os.path.splitext(filename)[0][1:], '%Y%j')
datetime.datetime(1998, 8, 25, 0, 0)
which would be filed in the 'august' bucket, files_by_month[7]
.