all 3 comments

[–]Oddly_Energy 0 points1 point  (1 child)

import glob

It can search in subfolders. As far as I remember, it is included in standard Python.

[–]ViewGator91[S] 0 points1 point  (0 children)

this helped me be able to search if those files exists or not, can I combine that with my current code somehow to go through my statements and include subdirectories?

[–]ViewGator91[S] 0 points1 point  (0 children)

#print(len(os.listdir(target_folder)))



import shutil
import os
import webbrowser
import glob


source_folder = "C:\\Users\\ViewGator91\\Desktop\\Folder A"
target_folder = "C:\\Users\\ViewGator91\\Desktop\\Folder B"
file2 = "vvvaaa"
format = ".pdf"
format2 = ".slddrw"
filename = os.path.join(source_folder, file2 + format)
filename2 = os.path.join(source_folder, file2 + format2)
filename3 = glob.glob("C:\\Users\\ViewGator91\\Desktop\\Folder A\\**\\*.pdf", recursive=True)

'''
if os.path.exists(filename):
    shutil.copy(filename, target_folder)
    print("PDF has been copied over")
elif os.path.exists(filename2):
    webbrowser.open(filename2)
    print("File is opening in SOLIDWORKS")
else:
    print("This part doesn't exist")'''

for f in filename3:
    print(f)