import os index = 0 for item in os.scandir("test"): print(item) index += 1 if index is 5: break