Avatar of rogerdjr
rogerdjr
Flag for United States of America asked on

batch file to delete all empty directories on the i drive

creating a batch file to delete all empty directories on the i drive - using after pkzip zips all files

Found this on the internet

i:
cd /
for /f "delims=" %%f in ('dir /ad /b i:\') do rd /s /q "i:\%%f"

but it deletes directories and files
Microsoft DOS

Avatar of undefined
Last Comment
rogerdjr

8/22/2022 - Mon
NVIT

This works:
@echo off
setlocal enabledelayedexpansion

for /f "delims=" %%f in ('dir /ad /b /s "i:\"') do rd /q "%%~ff"

Open in new window

ASKER CERTIFIED SOLUTION
Bill Prew

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
rogerdjr

ASKER
Shows access denied for all folders see attached image
batchfile.JPG
Bill Prew

sounds like the user running the script doesn’t have access to those folders.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
rogerdjr

ASKER
I am the user and i have no problem editing and deleting folders both with a batch file and manually