How to delete empty folders from a given directory in windows with a script

Posted by Nicola Peluchetti on Super User See other posts from Super User or by Nicola Peluchetti
Published on 2012-07-03T16:53:49Z Indexed on 2012/07/03 21:18 UTC
Read the original article Hit count: 245

Filed under:
|
|

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

© Super User or respective owner

Related posts about windows-7

Related posts about script