Very much my thinking, especially when there are no significant commands you need to shell out to:
import sys, pathlib
basedir = pathlib.Path(sys.argv[1])
for i in range(1, 501):
if not (basedir / f'{i:04}_A.csv').is_file():
print(i)