4/21/2023

get all txt or specific file in subfolder, python code example

 refer to code:


.

import glob
import os

def find_txt_files():
current_dir = os.getcwd()
txt_files = glob.glob(current_dir + '/**/*.txt', recursive=True)

for txt_file in txt_files:
print(txt_file)

if __name__ == "__main__":
find_txt_files()

..


Thank you.

πŸ™‡πŸ»‍♂️


No comments:

Post a Comment