Shaam
Shaam

Reputation: 92

Execute multiple command prompt commands in batch file

I need to created a .bat file which does the following things :

  1. Go to a folder which is found on Desktop, say "Test"
  2. Delete all files which is found in that folder, without asking for confirmation
  3. Open the folder "Test" after deletion.

All the commands should be each line for every step mentionned above.

I have tried the following code, but it is not what i'm expecting to do. Steps 1 and 2 is correct, but the folder is not opened.

start cmd.exe /k "cd Test && del * /Q && ."

Upvotes: 0

Views: 442

Answers (1)

phuclv
phuclv

Reputation: 41794

You need the start command to open programs/files/folders. To open the current folder in explorer use start ., not .. So the final result will be

start cmd.exe /k "cd Test && del * /Q && start ."

Upvotes: 1

Related Questions