cmd - How do I iterate over files/directories with names that do not match a wildcard? -
from within batch script file, following code deletes folders begin name preceding *, denoting wildcard. how write loop iterates on files/folders don't match? eg; ![*abc]
rem remove unwanted files/directories /d /r %%g in ("local\partialfilename*") ( rmdir /q /s %%g )
create temp dir, move matching files there, delete remain, , move them back. since move on same drive doesn't require copy, fast.
md ..\foo move *abc ..\foo rd . /s /q move ..\foo\* . rd ..\foo
the first rd command generate error message, can ignored.
Comments
Post a Comment