How do i delete all sub folders and files inside a parent folder without deleting parent folder

40 Views Asked by At

I am running the below command on Mac to delete all subfolders and files without deleting the parent folder.

rm -rf playwright-report/*

What will be the equivalent command for a Windows 10 OS?

I tried:

del /s /q playwright-report

But it's only deleting files, not subfolders inside the parent folder.

1

There are 1 best solutions below

1
Mr.Key7 On
@echo off
set "directory=C:\Users\Admin\Desktop\todel"
if exist "%directory%" cd /d "%directory%"
if "%cd%" EQU "%directory%" rd /s /q . 2>nul

replace C:\Users\Admin\Desktop\todel with your folder path ...playwright-report