<jupyter_start><jupyter_text>Search directories  import module...<jupyter_code>import os<jupyter_output><empty_output><jupyter_text>how to find documentation: the standard library... https://www.python.org is your friend... https://docs.python.org/3 is where you find the answers...https://docs.python.org/3/library/os.html for our module...  so lets play with the os module...<jupyter_code># Set the directory you want to start from
root_dir = 'D:\\DTM 25 Sjo\\'

for dir_name, subdir_list, file_list in os.walk(root_dir):
    print('Found directory: %s' % dir_name)   # note the formating in the print statement....
    for file in file_list:
        print('\t%s' % file) 
    print ('Total nuber of files in directory: %i' % len(file_list))<jupyter_output><empty_output><jupyter_text>find all empty directories...<jupyter_code># Set the directory you want to start from
root_dir = 'D:\\DTM 25 Sjo\\'

for dir_name, subdir_list, file_list in os.walk(root_dir):
    
    if (not len(file_list)): # if directory contains no files
        print('\t%s has no files and subdirectories...' % dir_name)<jupyter_output><empty_output><jupyter_text>find all the files with extention...<jupyter_code># Set the directory you want to start from
root_dir = 'D:\\DTM 25 Sjo\\'

for dir_name, subdir_list, file_list in os.walk(root_dir):
    # print('Found directory: %s' % dir_name)
    for file in file_list:
        if file.endswith('.xyz'):
            print('\t%s' % file)<jupyter_output><empty_output><jupyter_text>copy all files wich contains a substring to new directory<jupyter_code># Set the directory you want to start from
root_dir = 'D:\\DTM 25 Sjo\\'
dest_dir = 'D\\temp\\'
sub_string = 'outside'

for dir_name, subdir_list, file_list in os.walk(root_dir):
    # print('Found directory: %s' % dir_name)
    for file in file_list:
        if sub_string in file:
            command = 'copy '+ dir_name + file + ' ' + dest_dir + file
            print(command)
            # os.system(command)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12419594260267194, 'fraction_numerical': 0.004948045522018802, 'mean_word_length': 3.7242990654205608, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 3, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '552230', 'license': 'MIT', 'n_tokens_mistral': 694, 'n_tokens_neox': 678, 'n_words': 198, 'path': '06 os module.ipynb', 'repo_name': 'boelek/Python-introduksjonskurs-sjodivisjonen-2018', 'size': '2021'}