what is the command line to delete shortcuts

Page 1 of 4 123 ... LastLast

  1. Posts : 416
    Win10 32bit v20H2
       #1

    what is the command line to delete shortcuts


    For reasons that are irrelevant to my post, I have deleted the extensions (.lnk) from my shortcuts. In File Explorer they shows under File Types as SHORTCUTS. I want to use a batchfile to delete them from a folder whose name is two words. The following code fails to do the job. What is wrong with it ? del c:\folder\folder name"<shortcut>". Working in x32Win10ProV22H2
      My Computer


  2. Posts : 112
    Windows 10
       #2

    You must enclose between quotation marks all the filename path included. As for your command, "del" interprets it as del <thing1> <thing2> where <thing1> is c:\folder\folder and <thing2> is name"<shortcut>" (with <shortcut> instantiated or whatever it's called). The correct command would be del "c:\folder\folder name\<shortcut>". Some cmd commands sometimes don't need quotating, possibly dir, cd and others, what may lead to confusion.
      My Computer


  3. Posts : 416
    Win10 32bit v20H2
    Thread Starter
       #3

    Thank you for taking an interest in my problem. Sad to say, the modification you suggested, still fails to do the required job.

    Happy Easter
      My Computer


  4. Posts : 1,191
    Windows 10
       #4

    You may have to elborate further because its hard to understand your issue.

    Just to address some things to make it clear

    - .lnk is the extension for shortcut files.

    Sebastian42 said:
    I have deleted the extensions (.lnk) from my shortcuts. In File Explorer they shows under File Types as SHORTCUTS.
    what does the above mean? are you trying to say that the extension has changed on some shortcuts? and you are now wanting to delete those shortcuts?

    outside of that the correct command would be del "c:\folder\folder name<shortcut>" You only need to encapsulate when there is a physical space at any point of the path.
      My Computer


  5. Posts : 416
    Win10 32bit v20H2
    Thread Starter
       #5

    'are you trying to say that the extension has changed on some shortcuts?' In the folder of concern to me, I had reason to change all the entries from shortcut.lnk to just shortcut.
    'and you are now wanting to delete those shortcuts?" YES
    The reason is irrelevant, but I can state it if it is necessary.

    'the correct command would be del "c:\folder\folder name<shortcut>"
    but that would NOT give the correct path since 'folder name' is another folder containing the 'shortcut' entries.
    However, I will try that command line instead of the one I had before, and see if that works.
    Will report back when tried.

    Have now tried it - sad to report, still does not work.
      My Computer


  6. Posts : 582
    Windows 10 Home
       #6

    Please note that even if you can't see the ".lnk" extension in File Explorer, you still must use it when deleting from the command line.

    del "c:\users\username\My Folder\myshortcut.lnk"

    Ben
      My Computer


  7. Posts : 16,954
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #7

    Sebastian42 said:
    I have deleted the extensions (.lnk) from my shortcuts.
    In File Explorer they shows under File Types as SHORTCUTS
    You are mistaken.
    If you had done what you said, File explorer would not refer to them as Type Shortcut but as Type File.


    Denis
      My Computer


  8. Posts : 6,378
    Windows 11 Pro - Windows 7 HP - Lubuntu
       #8

    I don't know why MS set Explorer to hide extensions by default. It is a good way to load malware by mistake as a file Maria.jpg.exe (an executable file) will show as Maria.jpg making you think it is a image file when it's not.
    Go to Control Panel\All Control Panel Items - File explorer options - View and un mark "Hide Extensions for known file types"

    To delete one shortcut file: del "c:\users\username\My Folder\myshortcut.lnk"
    To delete all shortcuts files: del "c:\users\username\My Folder\*.lnk"
      My Computers


  9. Posts : 745
    Windows 10/11
       #9

    Please show us a screenshot like the following with "File name extensions" checked and the "File extension" column added. Note that showing of file name extensions makes no difference for shortcuts, but it's good to enable for clarification in regards to other file types.

    what is the command line to delete shortcuts-1.png
      My Computer


  10. Posts : 416
    Win10 32bit v20H2
    Thread Starter
       #10

    Ben Myers
    del C:\folder\folder name\*.lnk
    does the trick !
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 04:32.
Find Us




Windows 10 Forums