Symbols on the windows

I'm trying to check the path of a symbolic link or junction point in windows. How do I do this? os.path.islink() does not work. It always returns False I create symbolic links with the following method:

 mklink /d linkPath targetDir mklink /h linkPath targetDir mklink /j linkPath targetDir 

I used the command line because os.link and os.symlink are only available on Unix systems.

Perhaps there are command line tools for this? Thanks

+6
source share
3 answers

Status of os.path.islink() docstring:

 Test for symbolic link. On WindowsNT/95 and OS/2 always returns false 

On Windows, links end in .lnk for files and folders, so you can create a function to add this extension and check with os.path.isfile() and os.path.isfolder() , for example:

 mylink = lambda path: os.path.isfile(path + '.lnk') or os.path.isdir(path + '.lnk') 
+2
source

This works on Python 3.3 on Windows 8.1 using the NTFS file system.

islink () returns True for a symbolic link (created using mklink) and False for a regular file.

0
source

You can try

 dir /al <myfile> 

Shows the target path in the commands:

 C:\>dir /al "Documents and Settings*" [...] 14.07.2009 06:08 <VERBINDUNG> Documents and Settings [C:\Users] 

NOTE. For strange Windows-OS links, as described above, it does not work without the "*"

I was looking for the same problem but have not found anything so far ...

0
source

Source: https://habr.com/ru/post/947577/


All Articles