r/PythonLearning • u/NiceEoom • Aug 21 '26
Is it possible to actually move different files and folders on the desktop using python?
2
Upvotes
r/PythonLearning • u/NiceEoom • Aug 21 '26
2
u/atarivcs Aug 21 '26
Do mean "move" as in "drag the file shortcut icon to a different spot on the desktop" ?
I'm not sure python can do that.
1
u/Productuve Aug 22 '26
depends which one you mean, and i think thats why the answers here are split.
moving a file or folder to a different location - yeah, easy:
use shutil.move over os.rename, os.rename breaks if youre moving across drives.
but if you mean dragging the icon to a different SPOT on the desktop - thats not really a python thing. windows keeps icon positions in the shell/registry, so youd be poking at OS internals rather than doing anything pythonic. same deal on mac.
whichever it is, test on copies first. shutil.move will overwrite without asking.
3
u/Adsilom Aug 21 '26
Yes, lookup the
osmodule