Batch-Datei: Ordner löschen, falls bestimmte Datei nicht vorhanden
Hallo,
ich möchte gerne im Verzeichnis D:\ABC alle Unterordner löschen, in denen keine Datei mit der Endung .xyz vorhanden ist. Wie könnte man sowas umsetzen?
Viele Grüße
Jan
ich möchte gerne im Verzeichnis D:\ABC alle Unterordner löschen, in denen keine Datei mit der Endung .xyz vorhanden ist. Wie könnte man sowas umsetzen?
Viele Grüße
Jan
Please also mark the comments that contributed to the solution of the article
Content-Key: 360562
Url: https://administrator.de/contentid/360562
Printed on: April 19, 2024 at 12:04 o'clock
7 Comments
Latest comment
Powershell:
Batch
gci "D:\ABC" -Directory | ?{$_.GetFiles().Extension -notcontains '.xyz'} | remove-item -Force -Recurse
@echo off
for /d %%a in ("D:\ABC") do (dir "%%a\*.xyz" || rd "%%a" /s /q)
gci "D:\ABC" -Directory | ?{$_.GetFiles().Extension -notmatch '\.(xyz|xxx|yyy)$'} | remove-item -Force -Recurse
gci 'D:\Abc\*' -File -Recurse -Include *.xxx,*.yyy -Force | del -Force