Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Deleting empty folders

  • 04-12-2007 4:51pm
    #1
    Registered Users Posts: 268 ✭✭


    Hi,

    Does anyone know of any command that can be run on a Windows file system to delete any empty folders?

    Thanks


Comments

  • Closed Accounts Posts: 311 ✭✭auggie2k


    Not really necessary to be honest because the user no space basically. Some programs require these "empty" folders for temporary files etc. Anyway, here's the deal...

    You don't need a program; you can do this at the command prompt. Open a command prompt window and navigate to the root folder of the drive in question. Enter this command:

    DIR /AD/B/S | SORT /R > EMPTIES.BAT

    The file EMPTIES.BAT now contains a list of all folders on your hard drive in reverse order. Use Word or another editor to put the filenames in quotes and add the prefix RD (with a space after RD) to every line in the file. In Word, you can do this easily by using Find and Replace to search for ^p (which represents the paragraph mark) and replace it with "^pRD " (quote, p, R, D, space quote), then hand-correct the first and last lines of the file if necessary. Save the modified EMPTIES .BAT file and exit your editor. Then simply launch the batch file. It will attempt the RD (remove directory) command on each folder, but the command will fail for any folder that is not empty.


  • Registered Users Posts: 268 ✭✭LillyVanilli


    Thanks but that seems nearly as much work as deleting them manually. The folders I want to delete are not Windows files but files created by an application.
    Basically it has created every folder from A-Z, including Ab, Ac, Ad, ...Zz.. Aba, Abb... So thousands of folders.
    If anyone else knows of a quicker way that would be great.
    Thanks


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    lynners wrote: »
    Thanks but that seems nearly as much work as deleting them manually. The folders I want to delete are not Windows files but files created by an application.
    Pretty much the same thing. Folders are folders.
    Basically it has created every folder from A-Z, including Ab, Ac, Ad, ...Zz.. Aba, Abb... So thousands of folders.
    If anyone else knows of a quicker way that would be great.
    Thanks
    What auggie posted is pretty much the most comprehensive way you're going to get. You could use a decent text editor like notepad++ to stick an "RD" at the start of every line in a matter of seconds. Even doing it manually (copy and paste) should take no more than a few minutes, which is far quicker than going into each folder manually.

    If you know that all the folders are empty, then CTRL + A, DEL


  • Closed Accounts Posts: 311 ✭✭auggie2k


    Not at all, this would do it really quick...
    auggie2k wrote:
    In Word, you can do this easily by using Find and Replace to search for ^p (which represents the paragraph mark) and replace it with "^pRD " (quote, p, R, D, space quote), then hand-correct the first and last lines of the file if necessary.


  • Registered Users Posts: 268 ✭✭LillyVanilli


    Damn, Thanks for your help. I was hoping there was a windows search function for empty files.
    Its a job for tomorrow though, Ive copied the file into word and it 450 pages long so its going to take me while!

    Edit: Actually if the filename is:
    V:\w\wY\wYP\wyPE
    I have to change it to be "V:\w\wY\wYP\wyPE RD" right?


  • Advertisement
  • Closed Accounts Posts: 311 ✭✭auggie2k


    Find and Replace in work can be done automatically, its quick.


  • Registered Users Posts: 268 ✭✭LillyVanilli


    Ok its done, but can you confirm that this is correct?

    before: V:\A\AB\ABE\ABEC\ABECD
    after: RD "V:\A\AB\ABE\ABEC\ABECD"


  • Closed Accounts Posts: 311 ✭✭auggie2k


    Looks good to me!


  • Registered Users Posts: 268 ✭✭LillyVanilli


    All done and dusted. Thanks a million Auggie. It looked alot more complex the first time I read it.

    Edit: Scrap that, didnt work, I deleted the first empty folder but no others


  • Closed Accounts Posts: 311 ✭✭auggie2k


    No problem, coding always looks complex ha! :-)

    end.


  • Advertisement
  • Registered Users Posts: 268 ✭✭LillyVanilli


    Scrap that, didnt work, it deleted the first empty folder but no others


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 92,415 Mod ✭✭✭✭Capt'n Midnight


    sort the list backwards so you are deleting the last folder alphabeltically first , doing this also means sub folders get deleted before main ones


  • Registered Users Posts: 268 ✭✭LillyVanilli


    The list is automatically sorted backwards, I tried it again and it didnt delete any folders this time.


  • Registered Users, Registered Users 2 Posts: 719 ✭✭✭Fionn101


    well done auggie , perfect way to solve the problem.

    How long did it take you to think of this , or have you done similar before ???

    We asked this question in work to see how people would try to solve it, I'm still waiting.........

    Fionn

    (yeah, Friday, and we ARE that bor3d)


Advertisement