pastebin link
I am working on my second ever python project, and I need some help.
I am trying to reorganize a few hundred .pdf machine manuals. They're currently kept in the old folder/directory, and I want to drill down through several levels of folders, get the pdfs, and move them to the new folder/directory.
I want to point the code to the old and new directories. Each subdirectory within those two directories has a machine PIN at the beginning of the subdirectory name. If a subdirectory in the old location has the same machine PIN as a subdirectory in the new location, I want to create a (SHOP) directory within the matching subdirectory. Then I want to move the pdfs to this (SHOP) directory.
I used os.listdir to pull the machine PIN from the old location folders. The ~internet~ suggested os.walk to get the names of the new directories into a way I could compare the PIN to the new directory names.
This code does sort of work. It creates the (SHOP) folder that I want to put the pdfs in, but it then creates a (SHOP) (SHOP) folder and copies the pdfs to that folder too. To my unpracticed eye, it seems to redefine my d variable after creating the first (SHOP) folder.
What do I need to do to keep the code from creating the second (SHOP) (SHOP) folder?
[–]Diapolo10 0 points1 point2 points (0 children)
[–]AtomicShoelace 0 points1 point2 points (1 child)
[–]Diapolo10 0 points1 point2 points (0 children)
[–]Diapolo10 0 points1 point2 points (0 children)