Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is it possible to specify more than one file name or mask for deletion with the DEL command in CMD?

Something like this...

del /p *.html & *.json

This command works only partially - it finds all files with html suffix and prompts for deletion, it doesn't understand the second part for files with json suffix and returns an error at the end saying that it is not an internal or external command.

And what about the ren command?

Is it possible to input something like...

ren "file 1 & file 2 & file 3" "file a file b file c"

... to sort of tell it to rename file 1, 2 and 3 to file a, b and c respectively?

Or is this simply not possible without either redesigning the CMD or using batch processing or scripting?

Is there no utilization for the and character (&) in CMD?

share|improve this question
add comment

1 Answer

Is it possible to specify more than one file name or mask for deletion with the DEL command in CMD?

Yes, just list them:

del /p *.html *.json



The & operator allows you to specify multiple commands on the same line, so when you run del /p *.html & *.json, you are telling it to delete all html files, and then to execute all json files which of course won't work since you cannot use wildcards in command names.


And what about the ren command?

No, the ren command is more restrictive. It could be extended to accept arguments in pairs, but it does not. You can use the & operator here (if you must), but you must re-specify the ren command (though it is much clearer to do them on separate lines):

ren "file 1" a & ren "file 2" b & ren "file 3" c
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.