Reputation: 19
I'm currently working on a program that will clean up my desktop by moving everything into corresponding folders that are within another folder. For example, when you run the script, it makes a folder on your desktop called "desktop items" and then within that folder are subfolders such as "documents" "applications" "code", etc. Right now I have the individual files on my desktop being stored correctly, but I'm not sure how I would handle the folders. I just want to store the already made folders within the "desktop items" folder. Thanks!
Upvotes: 0
Views: 59
Reputation: 4866
You can make use of shutil
module. The function shutil.move(src, dst)
will do the trick.
Where src
will be the already made folder and dst
will be the folder "desktop items".
Edited:
For an arbitrary number of folders you can use module os
like this:
for elem in os.list("desktop_path"):
if os.path.isdir(os.path.join("desktop_path", elem)):
shutil.move(os.path.join("desktop_path", elem), "desktop items folder")
Upvotes: 1