Remove directory tree without following symlinks
Steven D'Aprano
steve at pearwood.info
Fri Apr 22 10:56:33 EDT 2016
More information about the Python-list mailing list
Fri Apr 22 10:56:33 EDT 2016
- Previous message (by thread): Can't run lpr from python on windows 2012 server
- Next message (by thread): Remove directory tree without following symlinks
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I want to remove a directory, including all files and subdirectories under
it, but without following symlinks. I want the symlinks to be deleted, not
the files pointed to by those symlinks.
E.g. if I have this tree:
parent/
+-- spam/
: +-- a.txt
: +-- b.txt
: +-- eggs/
: : +-- c.txt
: : +-- surprise -> ../../parent
: +-- d.txt
+-- e.txt
and I call remove_tree("parent/spam"), I want the result to be:
parent/
+-- e.txt
(Assuming that I have permission to delete all the files and directories.)
What should I use for "remove_tree"? Do I have to write my own, or does a
solution already exist?
--
Steven
- Previous message (by thread): Can't run lpr from python on windows 2012 server
- Next message (by thread): Remove directory tree without following symlinks
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list