Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have lots of symbolic links (windows 7). How to know if there are working or if they are dead (ie original file has been deleted/moved/renamed) ? I tried

if not exist mylink.txt echo The link is dead

but this doesn't work : if the link exist, if exist always answer true regardless if the link is dead or not.


share|improve this question

1 Answer 1

up vote 0 down vote accepted

You can use fsutil to check if both the symbolic link file and the linked file exist.

fsutil file queryfileid mylink.txt
if errorlevel 1 echo The link is dead

If you want to check all symbolic links in a folder, you can use

FOR %%f IN (*) DO (
  fsutil file queryfileid %%f
  if errorlevel 1 echo The link is dead

But you should take care. fsutil might also exit with exit code 1 if an error occurs.

share|improve this answer
Thanks! Is there a quick solution for deleting all symbolic links that are dead in a folder? I imagine it is possible with your fsutil, but I don't know how to make such a loop... – Basj Jun 15 '13 at 9:04
@JosBas I added a for loop to my answer. You can use that to walk through all files in a folder. But you should take care, fsutil might exit with exit code 1 not only for dead links, but also when other errors occur. You should echo the file names first before running a bat file which deletes the files (replace the echo with a del %%f)! – Werner Henze Jun 17 '13 at 7:54
thanks a lot Werner! – Basj Jun 17 '13 at 12:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.