How to Bulk Delete Symbolic Links (symlinks) in Windows

DeeDoe
2 min readSep 6, 2023

While the scenario is likely a rare case, if you ever find yourself needing to delete a bunch of (presumably broken) symbolic links (symlinks) in a given directory, below is a simple way to get that done.

Why would anyone need this?

In my case, I was re-organizing the files and folders in my various hard drives and had one really large directory/folder that simply would not move after it hit 24%. The progress window simply stopped showing any data transfer rate and the progress bar wouldn’t move. No errors popped up to indicate any issues or provide the typical move-related issue options to “Skip” or “Cancel”.

In revealing the details of the progress window, I navigated to the file that it seemed to be stuck on and it turned out to be a symbolic link to a file that didn’t exist. Deleting that symbolic link allowed the move to resume but it would stop time and time again. Each time, it was yet another broken symbolic link preventing the directory move.

Since, this folder directory seemed to be full of these symbolic links spread out across all different subfolders or subdirectories, I needed a quick way to delete all the broken symbolic links within all those different folders so that I could finish moving the directory and found this. Instructions shared below.

How to Bulk/Mass Delete Symbolic Links in a Directory

Note: This will delete all symbolic links (symlinks) in a given directory along with any symbolic links found in any sub-directories within that directory. So, if you need a way to only delete broken ones, this instructional is not for you.

Open a command prompt (Command Prompt CMD) and use either one of the commands below (or both if applicable).

For symbolic links that lead to a directory use:

FOR /F "usebackq delims=" %a IN (`DIR /a:l /s /b "C:\Path\To\Directory\"`) DO RMDIR "%a"

For symbolic links that lead to a file use:

FOR /F "usebackq delims=" %a IN (`DIR /a:l /s /b "C:\Path\To\Directory\"`) DO DEL "%a"

If you run into file access issues, run command prompt with administrative privileges.

Hope that helps some random person out there!

--

--

DeeDoe

Everyone is necessarily the hero of their own life story.