I have 2 directories, one with .json and one with .png files. I need to check if the png has a json file in the second folder with the same name and if yes, i need to put that png in a third folder.
I need to make a Python script (3.7) for doing that. Since I don't use Python usually I have a problem of implementing that. Also the names of files saved to the third directory should be saved as increasing numbers ("1.png", "2.png", "3.png" ...).
My idea was to do something like this:
import os
for name in os.listdir(directory):
for filename in os.listdir(directory2):
# checking if filename in directory2 with the name from the first directory
# if the name is same, save it in the third directory
# else continue
Is it possible to implement that with the os library because I didn't find a solution for that. If not, how can I solve this?