import os
def check_file_exists(directory, pattern):
# Extract the prefix from the pattern
prefix = pattern
with os.scandir(directory) as it:
for entry in it:
if entry.is_file() and entry.name.startswith(prefix):
return True
return False
directory = '/home/syy/Aplio_500/20230823'
pattern = 'Aplio_500-20230823-57'
if check_file_exists(directory, pattern):
print("File exists")
directory = '/home/syy/all_measure_img/imgs/H002/room4/Aplio_500/20230714/'
if os.path.isdir(directory):
print("Directory exists")