user1224433
user1224433

Reputation: 23

Using Del in a script

I am using del in a script like this:

del C:\Users\Eric\Desktop\dir\*.*

When the script runs the command prompt has me enter y or n for yes or no if I want to run the script. I do not want it to prompt me, I just want it to do it. How could I achieve this?

Thanks

Upvotes: 0

Views: 525

Answers (3)

Bali C
Bali C

Reputation: 31231

You can either use the /q switch as CognitiveCarbon suggested. Along with the /f to delete read-only files and /s for recursive deletion.

You could also pipe the y answer to the command like this:

echo y| del c:\Users\Eric\Desktop\dir\*.*

Upvotes: 1

CognitiveCarbon
CognitiveCarbon

Reputation: 191

del c:\Users\Eric\Desktop\dir\*.* /q

The /q switch turns off confirmation.

Upvotes: 4

If this is a bash script (assuming del is aliased to rm) as the tag suggests, use rm -rf file or directory Be careful though, this forces a recursive delete and will not prompt you!

Upvotes: 1

Related Questions