General discussion

  • Creator
    Topic
  • #2318216

    Batch file for Search & Delete

    Locked

    by link999 ·

    I need to create a batch file that will search for, and delete, folders on a hard drive.

    For example, say I had three folders called “HAPPY”. Something like this:

    1) c:\My Documents\Happy\
    2) c:\Windows\System32\Happy\
    3) c:\My Music\Rock\Happy\

    I need a batch file that would be run from the root of “C:\” that would find and delete all three of the “Happy” folders.

    It has to be a BATCH file. It has to be able to run from within DOS.

All Comments

  • Author
    Replies
    • #3373480

      Batch file for Search & Delete

      by d_v ant ·

      In reply to Batch file for Search & Delete

      The following will work. I have not been able to figure out how to make it search for a folder named “Happy”, but as long as the folders are always in the same place, just substitue the path shown for the folders actual locations.

      rd /S /Q C:\Mydocu~1\Happy
      rd /S /Q c:\Windows\System32\Happy\
      rd /S /Q c:\MyMusi~1\Rock\Happy\

      the /S remavoes all directories and files in the folder and the /Q will stop it from prompting you for confirmation.
      You must use the short filename. To determine what the short name is, from a command prompt, run the command dir /X in the parent directory and it will display the short filname for you.

      Hope this helps.

    • #3374008

      Batch file for Search & Delete

      by seandurcan ·

      In reply to Batch file for Search & Delete

      Norton used to have a utility which could find the directory by typing NCD HAPPY. Apart from that, you’d be on a hiding to nothing on a “Seek and Destroy” mission. DOS is extremely basic and not really User friendly.

    • #3373975

      Batch file for Search & Delete

      by jackofalltech ·

      In reply to Batch file for Search & Delete

      This could be done strictly in batch but it would be a royal pain. An easier way is to get the free utility SWEEP (sorry, no URL) and then the batch file would be


      @Echo
      Off
      CD \
      Sweep DelTree /Y happy

      Ralph

    • #3374429

      Batch file for Search & Delete

      by link999 ·

      In reply to Batch file for Search & Delete

      This question was closed by the author

Viewing 3 reply threads