0

The title has the question, how can I have something like "except this" is cmd.

1 of the reasons that I need this is to delete every file except 1. Some people will tell me this is a duplicate of this question. But the answers aren't good and are for files. This is only an example, I need this for folders and other operations.

This question meight be bad.

Ali
  • 33
  • 7
  • Command prompt (cmd) is not really suitable for this and does not natively support except operations. Powershell however does. – LPChip Jul 22 '19 at 14:04
  • @LPChip I don't use PowerShell, do you know the command? I know that the extension is .ps1 . If you know PowerShell is the importing and exporting the same? (How >,>> and < work) – Ali Jul 22 '19 at 14:33
  • Powershell does piping from command to command to command. It does understand everything CMD does, but it does a lot more and better. – LPChip Jul 22 '19 at 14:38
  • I can't help you with the powershell command because you were not very specific in your question. – LPChip Jul 22 '19 at 14:38
  • So the conclusion is it can't be done. – Ali Jul 22 '19 at 14:42
  • The post you linked seems to answer the question. – harrymc Jul 22 '19 at 14:52
  • 2
    Possible duplicate of [MS-DOS command to delete all files except one](https://superuser.com/questions/112136/ms-dos-command-to-delete-all-files-except-one) – harrymc Jul 22 '19 at 14:52
  • "So the conclusion is it can't be done" - Just because you can't doesn't mean it can't. Yes it can be done. But then again, forfiles can do it in cmd. But as per your own question, that was just an example, and you are looking for something else, but your question does not specify what else, so how can I know what else you want? Powershell can pipe to a filter object that can exclude stuff but it depends on each case how the filter object is used, such I can't give an example. – LPChip Jul 22 '19 at 21:07
  • And some cmdlets have exclude parameters, such as get-childitem which is used to get a list of files. (https://stackoverflow.com/questions/19207991/how-to-exclude-list-of-items-from-get-childitem-result-in-powershell) – LPChip Jul 22 '19 at 21:19

0 Answers0