0

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 && ."

1 Answer 1

1

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 ."
Sign up to request clarification or add additional context in comments.

2 Comments

@aschipfl it's necessary. Typing the folder name or . in the command line will result in '.' is not recognized as an internal or external command, operable program or batch file.
@aschipfl it depends. If you want to open in a new instance of cmd then it's necessary

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.