- by Adrian Andronic
I'm having trouble making folders that I create go where I want them to go. For each file in a given folder, I want to create a new folder, then put that file in the new folder. My problem is that the new folders I create are being put in the parent directory, not the one I want. My example: def createFolder(): dir_name = 'C:\\Users\\Adrian\\Entertainment\\Coding\\Test Folder' files = os.listdir(dir_name) for i in files: os.mkdir(i) Let's say that my files in that directory are Hello.txt and Goodbye.txt. When I run the script, it makes new folders for these files, but puts them one level above, in 'C:\Users\Adrian\Entertainment\Coding. How do I make it so they are created in the same place as the files, AKA 'C:\Users\Adrian\Entertainment\Coding\Test Folder'?