I have a folder called test .
Within this folder there are 1000 sub-folders numbers from 1 to 1000.
Inside each of these subfolders there is another folder called reports
Within each reports folder there is a file called report.json
I need to get each of these report.json files and move them to the destination folder.
I have the following script:
import shutil
import os
import glob
source = "C:\Users\usuario\Desktop\teste\**numero_da_pasta**\reports\"
dest1 = dst = "C:\Users\usuario\Desktop\destino\"
files = os.listdir(source)
for f in files:
if f == "report.json":
shutil.move(source+f, dest1)
It is able to move the report.json file to the destination folder, however every time I have to manually change the folder number to 2, 3, 4 etc ...
How do I make this process all automated? I can not do it.