fix error

This commit is contained in:
2024-08-15 13:59:57 +02:00
parent 31b2f7ddc6
commit aca340cde8
2 changed files with 25 additions and 5 deletions

View File

@@ -1,15 +1,14 @@
#! /usr/bin/env python3 #! /usr/bin/env python3
import os, sys import os, sys
def show_all_files_directory(dir_path = str, search_endung = False, search_string = False, exclude_folder = "glob"): def show_all_files_directory(dir_path = str, search_endung = False, search_string = False):
li_all = [] li_all = []
for (root_folder, dirs, files) in os.walk(dir_path, topdown=False): for root_folder, dirs, files in os.walk(dir_path, topdown=False):
for name in files: for name in files:
FullPATH = [str(os.path.join(root_folder, name)), name] FullPATH = str(os.path.join(root_folder, name))
print(FullPATH)
if not search_endung is False: if not search_endung is False:
if FullPATH.endswith(search_endung): if FullPATH.endswith(search_endung):
li_all.append(FullPATH) li_all.append(FullPATH)
elif not search_string is False: elif not search_string is False:
if not FullPATH.find(search_string) == -1: if not FullPATH.find(search_string) == -1:
li_all.append(FullPATH) li_all.append(FullPATH)
@@ -18,6 +17,7 @@ def show_all_files_directory(dir_path = str, search_endung = False, search_strin
return li_all return li_all
def main(check_list = list, main_folder_in = str): def main(check_list = list, main_folder_in = str):
output_list = [] output_list = []
for folder_name in check_list: for folder_name in check_list:

20
play_with_os/test.py Normal file
View File

@@ -0,0 +1,20 @@
import os
def show_all_files_directory(dir_path = str, search_endung = False, search_string = False):
li_all = []
for root_folder, dirs, files in os.walk(dir_path, topdown=False):
for name in files:
FullPATH = str(os.path.join(root_folder, name))
if not search_endung is False:
if FullPATH.endswith(search_endung):
li_all.append(FullPATH)
elif not search_string is False:
if not FullPATH.find(search_string) == -1:
li_all.append(FullPATH)
else:
li_all.append(FullPATH)
return li_all
print(show_all_files_directory(dir_path="/home/jonnybravo/Downloads", search_string=".txt"))