Hi I have a folder of dcm files i want to change into png files to put into a png folder. Here is the code I have done:
dcm_folder= '/Users/riaroque/Desktop/DCM Pneumonia cases'
PNG_folder= '/Users/riaroque/Desktop/PNG folder'
os.makedirs(PNG_folder, exist_ok=True)
for dcm_file in os.listdir(dcm_folder):
dcm_file_path = os.path.join(dcm_folder, dcm_file)
png_file_path = os.path.join(PNG_folder, '%s.png' % dcm_file)
try:
convert_file(dcm_file_path, png_file_path)
print (dcm_file_path, '-->', png_file_path)
except:
print ('FAIL>', dcm_file_path, '-->', png_file_path)
It's giving me a list this error
FAIL> /Users/riaroque/Desktop/DCM Pneumonia cases/UP0084.dcm --> /Users/riaroque/Desktop/PNG folder/UP0084.dcm.png
I can see that from the error its not properly converted having .dcm.png at the end, How do I remove the .dcm and just replace it with .png?