edited
i created symlinks to a directory, on Widnows7, using mklink
command line:
mklink /d books config
i'm trying to delete it with python 2.7 (still on windows).
>>> os.remove('books')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
sym = symlink_to_dir
os.unlink(sym) #
WindowsError: [Error 5] Access is denied: 'books'
there are no restrictions on that machine, i'm admin,
and i didn't have problems to delete it from Windows (del books)
There's no problem deleting a link to a file (as opposed to a dir).
why is that?
edit "del" didn't work, it just didn't return an error.
cd
'd to the symlink (or a subdirectory through the symlink) in a running cmd.exe shell? – Marriedos.system('del '+sym)
. That gives you no way to tell whether it succeeded or failed, it will not work ifsym
has any spaces or various other special characters, etc. If you really need to run an external command, usesubprocess
, notos.system
. – Married'static'
the name of the file? – Married