I need to make a script that will iterate through all the directories inside a directory. It should go into each directory, get its name and save it to a variable and comes back out, and then loops.
for dir in os.walk(exDir):
path = dir
source = #dir trimmed to anything after the last /
For each iteration of your for loop,
dir is a tuple of format
(filepath, subdirectories, files). As such
dir will give you the filepath.
It sounds like you just want to
os.chdir for each folder recursively in
exDir in which case the following will work:
for dir in os.walk(exDir): os.chdir(dir) ...