I am trying to check if the file name exists in a folder, for that I am storing expected file names in a list (expected_file_names) and actual file names are returned in another list (actual_file_names) using python. I am able to get the file names from the folder, but how do I iterate over each list item in actual_file_names and check if substring of it matches with another list item.
Goal
I am trying to get whether filename which starts with DMAMiddleware exists in a folder , actual filename is like DMAMiddleware10.20.20.jar . I want to check whether substring DMAMiddleware exists or not in a lists (expected & actual lists)
Problem
I am not clear on how to compare substrings in a list
Can someone provide me with an example or how this can be achieved. Thanks in advance.
actual_file_names = ['', 'python', 'cmdb_dma_map.json', 'mappings.json', 'vendor_provided_binaries.json',
'vendor_provided_binaries_custom.json', 'DMAPremiumDatabase10.50.000.000.jar',
'DMAPremiumMiddleware10.50.000.000.jar', 'DMAPremiumUtilities10.50.000.000.jar',
'dma_oo_client_bin_linux.zip', 'dma_oo_client_bin_linux.zip.MD5', 'dma_oo_client_code_linux.zip',
'dma_oo_client_code_linux.zip.MD5', 'DCAFlowUtilities1.0.0.0.jar', 'DCAKafkaWriter1.0.0.0.jar',
'DCAUtilities1.0.0.0.jar']
expected_file_names = ['python', 'cmdb_dma_map.json', 'mappings.json', 'vendor_provided_binaries.json',
'vendor_provided_binaries_custom.json', 'DMAPremiumDatabase.jar', 'DMAPremiumMiddleware.jar',
'DMAPremiumUtilities.jar']
for f in expected_file_names:
for g in actual_file_names:
if f in g:
print "All file names exists in " + g
else:
print "file name "+g+" doesn't exists"