in sizeand have lot of files in :\windows\system if want to find the total size of all the files in this directoryi can use os path getsize(and os listdir(together totalsize for filename in os listdir(' :\\windows\\system ')totalsize totalsize os path getsize(os path join(' :\\windows\\system 'filename)print(totalsize as loop over each filename in the :\windows\system folderthe totalsize variable is incremented by the size of each file notice how when call os path getsize() use os path join(to join the folder name with the current filename the integer that os path getsize(returns is added to the value of totalsize after looping through all the filesi print totalsize to see the total size of the :\windows\system folder modifying list of files using glob patterns if you want to work on specific filesthe glob(method is simpler to use than listdir(path objects have glob(method for listing the contents of folder according to glob pattern glob patterns are like simplified form of regular expressions often used in command line commands the glob(method returns generator object (which are beyond the scope of this bookthat you'll need to pass to list(to easily view in the interactive shellp path(' :/users/al/desktop' glob('*'list( glob('*')make list from the generator [windowspath(' :/users/al/desktop/ png')windowspath(' :/users/aldesktop/ -ap pdf')windowspath(' :/users/al/desktop/cat jpg')--snip-windowspath(' :/users/al/desktop/zzz txt')the asterisk (*stands for "multiple of any characters,so glob('*'returns generator of all files in the path stored in like with regexesyou can create complex expressionslist( glob('txt'lists all text files [windowspath(' :/users/al/desktop/foo txt')--snip-windowspath(' :/users/al/desktop/zzz txt')the glob pattern 'txtwill return files that start with any combination of characters as long as it ends with the string txt'which is the text file extension reading and writing files