Delete file by command line with different type

Asked

Viewed 566 times

3

It has 2 directories, their contents are the same, but in one of them there can only be java files

and the other only files that are not java

In the Resources folder are those not java

src main Resources>del/s *.java

In the java folder are only the files . java

src main java>del/s ???

??? = all aquives with different span of java

  • I really don’t understand the question or the problem you’re having with the command del...

1 answer

3


The command del do not delete read-only files, unless you force it with /f. So, one way to delete all files except the . java is to make the . java read-only and then return them.

Read-only:

cd src\main\java
attrib +r *.java

Delete all files (the . java will be because they are read-only):

del /q *.*

Being the /q why cmd don’t ask if you’re sure.
Finally, return the . java files to normal:

attrib -r *.java

Another solution would be to integrate the . java into another temporary folder and then return it to the str main java folder.

Something like:

cd src\main\java
copy *.java TEMP_DIR
del *.* 
copy TEMP_DIR\*.java src\main\java
  • 2

    Nice play on the attrib!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.