Results 1 to 9 of 9
  1. #1
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Hatsukaichi, Hiroshima, Japan
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Deleting Shortcuts problem (XP Pro (SP1))

    Does anyone know how I can delete shortcuts to folders from inside a batch file. For example, suppose I have two short cuts: one to D:tempfolder and another to dldltext.txt. To delete the shortcut to the text document I would type:

    DEL "dldtext.txt.lnk" /f /q

    or, to delete all txt files:

    DEL "d:*.txt.lnk" /f q/

    But how do I delete links to folders?

    Thanks

    Chris (Hunt)

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Deleting Shortcuts problem (XP Pro (SP1))

    If you use foldername.lnk, does it not work? I can rename using that syntax, but I didn't try to delete.

  3. #3
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Deleting Shortcuts problem (XP Pro (SP1))

    Chris

    Jefferson is correct; they are all of the form "folder name maybe with spaces in it.LNK".

    Unless there's something common to the filename portion, you'd have to do them individually.

    I would <big>not</big> advise something of the form del /f /q d:*.lnk for that way unhappiness will occur...

    John
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  4. #4
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Hatsukaichi, Hiroshima, Japan
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Deleting Shortcuts problem (XP Pro (SP1))

    Thanks for the replies,

    I really need a blanket command to delete all the shortcuts to folders at once. Since there isn't one it looks like I'll have to figure out why Windows doesn't like it if I copy shortcuts out of the Recent Folder and then copy them back. When I do this the shortcuts don't show up via the Start menu. Can anyone think of a reason why this is? If I can copy the shortcuts out of the Recent folder then I can empty the recent folder and copy back just the type of shortcuts I want. This Recent folder seems a really nuisance to work with.

    Chris

  5. #5
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Deleting Shortcuts problem (XP Pro (SP1))

    Chris

    To do what you want is going to require some slightly more complicated BATch programming, where you enumerate all the shortcut-to-folders filenames, probably using DIR, and then deleting them with DEL. If I said FOR /F would you know what I'm talking about? And without some conditional logic you'd have to take all the folder shortcuts...

    if you could give me a DIR /B command which lists all the folder shortcuts to want to delete, and only those you want to delete, I will give you a one-line BATch file that will do it!*

    John

    PS You seem to be going to an enormous amount of effort for something which you could use Explorer to highlight and delete!

    * I reserve the right to increase the number of lines supplied above 1...!
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Deleting Shortcuts problem (XP Pro (SP1))

    Could a batch file identify folder names by the existence of only one dot in the filename+extension (or 0 dots in the filename sans extension)? Actually, that's probably not a reliable indication...

  7. #7
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Hatsukaichi, Hiroshima, Japan
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Deleting Shortcuts problem (XP Pro (SP1))

    Thanks for the offer John, I don't want to put you to any trouble.

    I've heard of what you are talking about but never used it . Since I'm focusing on the Recent folder I don't actually know what goes into it! I've never exactly figured out when Windows adds a shortcut and what kinds of shortcuts it chooses to display. What I do know is that I would like the Recent folder to display shortcuts to the following extensions only:

    .acd, .doc, .txt, .cdr, .cpt, .xls

    I think the simplest approach might be for me to make my own "Recent" folder. I can copy all the shortcuts I want out of the real Recent Folder and then delete all the shortcuts in it.. I can use DELOLD to keep my own folder from accumulating too many shortcuts. I can use TweakUI to stop the real Recent folder from showing on the Start Menu.

    I realise I could put a shortcut to the Recent Folder on the desktop and then periodically clean it out by hand but I will confess that I'm bugged by the fact that I can't figure out how to do it automatically. Call me stubborn.

    There is one more idea I've just thought of. I'll try it out and then let you know how it goes.

    More soon!

    Chris

  8. #8
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Hatsukaichi, Hiroshima, Japan
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Deleting Shortcuts problem (XP Pro (SP1))

    I think I got it sussed!

    My problem was that Windows XP didn't like me copying files back into the Recent Folder, they just wouldn't show via the Start Menu. The solution that seems to be working is to use Karen's Relicator. I can call this from a batch file. I run it twice. The first time I copy across the kind of shortcuts I want (the replicator has a customisable filter) into a temporary folder. Then I run the replicator again. This time I have it set to mirror the contents of the Recent Folder with that of the temporary folder. The result is that Karen's replicator deletes all the shortcuts in the Recent Folder that are not in the temporary folder. I haven't actually copied the files back into the Recent Folder so they still show up via the Start Menu.

    I still need to use DELOLD to weed out old shortcuts but that should be straightforward. I'll need to test it a few more times to make sure but the job looks a good 'un.

    Thanks, John, for the idea about using FOR - it helped me to think of a way to use Karen's Replicator., and thanks Jefferson for your replies, too

    All the best,

    Chris

  9. #9
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Deleting Shortcuts problem (XP Pro (SP1))

    If you've ended up with a way that works, that's good!

    John
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •