Author Topic: Simple Win PoSH script  (Read 2121 times)

0 Members and 1 Guest are viewing this topic.

Offline Joe

  • B&
  • x86
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Simple Win PoSH script
« 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. ^_^
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Simple Win PoSH script
« Reply #1 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?

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Simple Win PoSH script
« Reply #2 on: April 03, 2008, 12:06:12 pm »
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!
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Simple Win PoSH script
« Reply #3 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" :) )

Offline Skywing

  • Full Member
  • ***
  • Posts: 139
    • View Profile
    • Nynaeve
Re: Simple Win PoSH script
« Reply #4 on: April 03, 2008, 03:30:04 pm »
rmdir (alias rd) in cmd will only remove empty directories, unless you use /s.

Offline Explicit

  • Hero Member
  • *****
  • Posts: 717
  • Hail Bender!
    • View Profile
Re: Simple Win PoSH script
« Reply #5 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.
Quote
Like all things in life, pumping is just a primitive, degenerate form of bending.

Quote
Hey, I don't tell you how to tell me what to do, so don't tell me how to do what you tell me to do! ... Bender knows when to use finesse.

[13:41:45]<@Fapiko> Why is TehUser asking for wang pictures?
[13:42:03]<@TehUser> I wasn't asking for wang pictures, I was looking at them.
[13:47:40]<@TehUser> Mine's fairly short.