Link to home
Start Free TrialLog in
Avatar of rogerdjr
rogerdjrFlag 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
Avatar of NVIT
NVIT
Flag of United States of America image

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
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rogerdjr

ASKER

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

sounds like the user running the script doesn’t have access to those folders.
I am the user and i have no problem editing and deleting folders both with a batch file and manually