How to delete empty folders from a given directory in windows with a script
- by Nicola Peluchetti
I'm using r.js as a build tool but as of today that tools doesn't give me the ability to delete empty folders in the build dir. I've found these two scripts
for /f "usebackq" %%d in ("dir /ad/b/s | sort /R") do rd "%%d"
for /f "delims=" %%i in ('dir /s /b /ad ^| sort /r') do rd "%%i">NUL
looking around the net but i always get
%%i was unexpected at this time.
or
%%d was unexpected at this time.
And i wouldn't know how to tell the script where my directory is.
My build script is
@echo off
where /q r.js || (
echo requirejs node package is not installed. You must install node, npm and then run npm install -g requirejs
goto :eof
)
node r.js -o app.build.js
:end
I need to tell the script to remove all empty directories which are located inside ../../js