Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there anyway to quickly remove many symbolic links in many folders that contains many other files. E.g some command in command prompt (be able to delete all slink created from day XX for example)?

Remove all objects that are symbolic link, all other objects remain. Now I only navigate folder by folder, manually select them in Windows Explorer (rearange all items by size, and symbolic links size 0KB, and shift key select all --> del) and remove slowly, maybe sometime mistake sl with another 0KB files. My younger bro drag & drop a lot of files with right click (Link Shell Extension Copyright (C) 1999 - 2008 by Hermann Schinagl already installed in PC, integrated into Windows Explorer) and he pick drop as symbolic link, it all became garbage. Thanks for reading.

[There's someone post a comment ask me that remove all s-links or only dead s-links, so I reply back but seem the comment below was deleted, I don't know why. It make my comment looks weird alone.].

share|improve this question
    
OK, you feel free explain both of case. For dead s-links and all s-links with details and description, thanks. –  Edward Dec 24 '11 at 2:48
    
People always seem to blame little brothers. It's almost never big brothers or little sisters, I observe. –  JdeBP Dec 24 '11 at 3:38
    
@JdeDp: That's because parents, which always blame us, don't call us big brothers/sisters. –  surfasb Dec 25 '11 at 10:14
add comment

2 Answers

Using the SFUA utility toolkit:

Finding symbolic links can be done the same ways as finding hard links: using the find command that is in Microsoft's SFUA utility toolkit, that runs in the Subsystem for Unix-based Applications:

find . -type l|xargs rm --

Using JP Software's TCC/LE:

This is a simple exercise in the use of attribute switches and the ordinary del command:

del /a:l *
You can, of course, use the /s, /p, and other options to the del command. And you can preview what would be deleted either by using del's /n option or simply by substituting dir for del.

Caveat

Both of these actually find reparse points. Symbolic links are but one form of reparse points. If you have others, such as junctions, you'll have to be careful about what parts of your directory tree you apply these commands to. Using date ranges to only delete files with recent creation dates (/[dc…]) might be profitable as well.

share|improve this answer
    
The TCC/LE version doesn't seem to work with junctions, because /s descends into junctions, rather than considering them to delete. /nj will stop that, but doesn't seem to solve the problem. The following seems to work, even though del claims to have deleted nothing: del /a:l /s /e /l * As a useful helper, this will list all such files: dir /a:l /s /nj /k /m so you can see if it worked. -Robin –  rlpowell Jan 22 '13 at 8:00
add comment

This is similar to JdeBP's answer, but it doesn't require any external software:

FOR /F "usebackq delims=" %%a IN (`DIR /a:l /s /b "C:\dir\with\symlinks"`) DO RMDIR "%%a"
share|improve this answer
    
Thanks you for such specific answer. –  Edward Feb 25 at 5:13
add comment

Your Answer

 
discard

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.