Import the `os` library to be able to get a list of all filenames in a directory for manipulation. ### Delete empty files in a directory Here's an example that deletes files that fulfill a certain condition (containing no data) within a directory. ```python # Opens files in directory and deletes them if they are empty. import os vaultDir = '/Users/nic/Dropbox/DownloadMyBrain/dmb-obsidian/Workshop/' files = os.listdir(vaultDir) for file in files: # print(file) # check if size of file is 0 if os.stat(vaultDir + file).st_size == 0: os.remove(vaultDir + file) print(file) ``` ### Get full path of file ```python os.path.basename(file) ``` This includes the path as well as the filename. ### Get filename of file ```python for subdir, dirs, files in os.walk(filePath + sourceDir): for file in files: head, filename = os.path.split(file) print(filename) ``` Output: ```plain Rat King.md Swarm, Manabane Scarabs.md Mavka.md Ramag.md Imy-ut Ushabti.md Moss Lurker.md Herald of Darkness.md Skeleton, Sharkjaw.md Shadow Beast.md ```