How to use glob.escape() function in python

41

import glob

files = glob.glob("D:\\**\\*.jpg",recursive=True)
# All jpg files
print(files)

#JPEGs files with special characters in their name
# set of special characters _, $, #
char_seq = "_$#"
for char in char_seq:
    results = "*" + glob.escape(char) + "*" + ".jpg"
    for file in (glob.glob(results)):
        print(file)

Comments

Submit
0 Comments