General discussion

  • Creator
    Topic
  • #2074738

    Delete command in a batch file?

    Locked

    by jim_rau ·

    I have a batch file I built with NotePad in Win95 and one of the commands is “del f:\slik-app\data\*.*”

    The batch runs fine except that this command requires a confirmation. I am using this as part of an automated process. I need to figure out what is needed in the batch so it does not ask for confirmation.

    Any ideas/answers???

All Comments

  • Author
    Replies
    • #3776331

      Delete command in a batch file?

      by yorkster ·

      In reply to Delete command in a batch file?

      use a /Q at the end of your delete statement, the Q is for quite mode.
      hope this helps
      note: this works in NT but I’m not sure about 95

    • #3776307

      Delete command in a batch file?

      by syscokid ·

      In reply to Delete command in a batch file?

      1. Create a text file that contains only the letter “y”. Call it y.txt.

      2. Change your command to del f:\slik-app\data\*.*

      • #3776224

        Delete command in a batch file?

        by jim_rau ·

        In reply to Delete command in a batch file?

        I remember this … thanks for the refresher but the echo is a better solution (see below).

    • #3776306

      Delete command in a batch file?

      by james schroer ·

      In reply to Delete command in a batch file?

      Try a del /y f:\slik-app\data\*.* or try del f:\slik-app\data\*.* /y If that doesn’t work I know for a fact this will. You will have to delete the directory but it will create the directroy back. deltree /y f:\slik-app\data
      if not exist f:\slik-app\data\nul md f:\slik-app\data

      • #3776221

        Delete command in a batch file?

        by jim_rau ·

        In reply to Delete command in a batch file?

        So I would have to add more lines to put the folder back … but the echo idea below is much better and the one above is OK too …

    • #3776275

      Delete command in a batch file?

      by syscokid ·

      In reply to Delete command in a batch file?

      I know for a fact mine works, but I think you might need a hard return after the letter y.

    • #3776270

      Delete command in a batch file?

      by jeng ·

      In reply to Delete command in a batch file?

      Comment on #1: DEL F:\slip-app\data /y only works for NT

      On #2: This will work. You can bypass the creation of a “Y” file by doing “echo Y | DEL F:\slip-app\data”. This will work with any version of DOS (of at least DOS 5.0).

      On #3: Becareful with DELTREE. It will do the deletion, but it will take out the subdirectories below it. After deleting the files, it will remove the subdirectory “F:\slip-app\data” itself. This is only available in Win9x. For NT, use “RD /S /Y”

      • #3776219

        Delete command in a batch file?

        by jim_rau ·

        In reply to Delete command in a batch file?

        You the MAN! What is best about this is I don’t need a text file to implement the idea, it kind of works wherever it is. Thanks!!!

    • #3776232

      Delete command in a batch file?

      by al hedstrom ·

      In reply to Delete command in a batch file?

      You need The Pipe:

      echo y | del c:\temp\*.*

      The character after the Y, pipe, is located above the backslash on my keyboard (yours may be different).

      This technique temporarily puts a “Y” in the keyboard buffer and feeds it back the next time DOS expects keyboard input – in this case, confirmation that you really know what you’re doing when you delete all files.

      Hope this helps.

      Al Hedstrom

      • #3776220

        Delete command in a batch file?

        by jim_rau ·

        In reply to Delete command in a batch file?

        Right answer but a bit slower than Al (sorry). Thanks for the time though …

Viewing 5 reply threads