How to delete all folder shortcuts and file shortcuts using windows command line?

13,681

If you do not want to delete the contents of a folder shortcut, right click it, go to properties and delete the target. That should leave you with a new shortcut that goes to my computer. Then you can safely delete that new one as its not pointing to any contents.

Share:
13,681

Related videos on Youtube

Breeze
Author by

Breeze

Updated on September 18, 2022

Comments

  • Breeze
    Breeze over 1 year

    I have a folder that contains lots of files and some folder/file shortcuts. I want to deletes these shortcuts (recursively) but I don't know how coz shortcuts don't have file extension (not sure true or not). May I know what command I can use to achieve this?

    I suppose the windows command should be like this:

    delete /S *.fileshortcut
    

    By the way, is there difference between a file shortcut and folder shortcut?

    • dtbnguyen
      dtbnguyen about 9 years
      You don't need the command line to do this if that's what you're thinking. Open up Windows Explorer. Type in 'type:shortcut' in the search filter box. Select all and delete. No difference between file and folder shortcut as you'll soon see.
    • Biswapriyo
      Biswapriyo over 6 years
      Say the folder is C:\test. Command:: for /R "C:\test" %x in ( *.lnk ) do (del /f /q %x ). Run it as admin.
  • Keith Miller
    Keith Miller about 4 years
    The OP was asking for Command line methods.
  • Braden Dodge
    Braden Dodge about 4 years
    That's true, but that doesn't make this method any less useful, especially if the op decides this method is more effective. Let's not forget the purpose of Q&A, to solve a problem
  • Keith Miller
    Keith Miller about 4 years
    True, so maybe look for problems more current than 2015 :D
  • Braden Dodge
    Braden Dodge about 4 years
    Jeez I guess I didn't notice it was that old
  • Keith Miller
    Keith Miller about 4 years
    LOL. I did the same thing when I started checking these forums.