Clan x86

General Forums => General Discussion => Topic started by: Joe on April 03, 2008, 12:57:37 AM

Title: Simple Win PoSH script
Post by: Joe on April 03, 2008, 12:57:37 AM
I'm looking for a script for Windows Powershell that can recursively delete empty folders. I recently removed a bunch of MP3s from a podcast that had been sorted into different artist folders, but I'm too lazy to delete the folders myself.

Thanks for anyone who can do this for me. ^_^
Title: Re: Simple Win PoSH script
Post by: iago on April 03, 2008, 09:28:17 AM
On Linux, I do:
rmdir *
or
rmdir */*
rmdir */*/*
etc.

Until I get deep enough. Does that work on Windows?
Title: Re: Simple Win PoSH script
Post by: MyndFyre on April 03, 2008, 12:06:12 PM
Quote from: iago on April 03, 2008, 09:28:17 AM
On Linux, I do:
rmdir *
or
rmdir */*
rmdir */*/*
etc.

Until I get deep enough. Does that work on Windows?

Nah, rd doesn't recursively remove.

I don't know why they removed deltree from Vista. :(

C'mon Joe, whip up a PowerShell script yourself!
Title: Re: Simple Win PoSH script
Post by: iago on April 03, 2008, 02:47:55 PM
"rmdir" only removes empty folders, which is why it works for me. Does Windows have a function that only removes empty folders?

(it'll be a funny day when I'm on a system where somebody aliases "rm -r" to "rmdir" :) )
Title: Re: Simple Win PoSH script
Post by: Skywing on April 03, 2008, 03:30:04 PM
rmdir (alias rd) in cmd will only remove empty directories, unless you use /s.
Title: Re: Simple Win PoSH script
Post by: Explicit on April 04, 2008, 01:55:35 AM
Might want to add /q (quiet) in there so it won't prompt you, not that it's necessary.