Coder Social home page Coder Social logo

hxseven / remove-empty-directories Goto Github PK

View Code? Open in Web Editor NEW
286.0 21.0 41.0 997 KB

A application that searches, displays and deletes empty directories recursively written in C#

Home Page: http://www.jonasjohn.de/red.htm

License: GNU Lesser General Public License v3.0

C# 79.11% Inno Setup 17.40% Batchfile 3.50%

remove-empty-directories's Introduction

Remove Empty Directories

RED finds, displays, and deletes empty directories recursively below a given start folder. Furthermore, it allows you to create custom rules for keeping and deleting folders (e.g. treat directories with empty files as empty).

Features

  • Simple user interface
  • Shows empty directories before deleting them
  • Supports multiple delete modes (including Delete to recycle bin)
  • Allows white and blacklisting of directories by using filter lists
  • Can detect directories with empty files as empty

System requirements

  • Windows 7 or 10
    • Version 2.2 should also still work with older Windows versions like XP or Vista
  • Microsoft .NET Framework 4.6.2 or later
    • The installer checks for the right version and installs it if missing

How to contribute to the project

You are very welcome to contribute code, translations, or anything else :)

Here are some tasks you can help with:

  • Look at open issues/bugs and try to fix them
  • Fix typos and general wording
  • Optimize user interface
  • Create a strategy/foundation for translations, are there any existing frameworks/concepts?
  • Add unit tests

History

The first version of RED was created by Jonas John around 2005.

Since then a small team of contributors helped to fix bugs and add new features.

Changelog

2.3

  • Disabled settings during active search or deletion process
  • Refactored the interface to improve the design and usability
    • Divided packed settings tab into three separate tabs
    • Renamed some options and captions to make more sense
    • Added more descriptions and examples to explain settings
    • Increased default window size and added more whitespace to make it look less crowded
  • Optimized config defaults
    • Set pause between deletions to zero because the default delete to recycle bin method is slow enough to not overwhelm the GUI
    • Deleted some unnecessary entries and updated some values
    • Removed *.tmp as default pattern to make the default settings safer because those files could still contain valuable data in some cases.
  • Long paths support and other improvements (contributed by gioccher, see #5)
    • Fix crash due to case sensitivity of paths
    • Speed up crawl and deletion by disabling UI updates (dubbed fast mode)
    • Long path support by switching to AlphaFS
    • And more minor improvements (see closed pull request #5 for details)
  • Ignore folders newer than N hours #3 (contributed by jsytniak, see #3)

2.2

  • Improved error handling
  • Added logging of errors and deleted directories
  • Added multiple delete modes (e.g. delete to recycle bin)
  • Implemented a function to delete a single empty directory
  • Implemented optional function to detect paths in clipboard
  • Infinite loop detection
  • Added a few new configuration settings
  • Removed counting method to increase speed
  • Replaced old custom settings module with the default settings framework of .NET to be more standard-compliant (This should fix problems some users had when starting RED)

2.1

  • Implemented a "Protect" and "Unprotect" function to let the user choose folders to keep
  • Implemented an update button for a fast update check

2.0

  • Created the installer (using NSIS)
  • Updated this readme file

1.9

  • Added better-looking icons to the GUI
  • Corrected and updates some texts

1.8

  • Finished the main parts of the application
  • Added XML configuration file

1.7

  • Removed some main parts of the new application and started using the "BackgroundWorker" for threading support.

1.6

  • Finished the first prototype of the C# version

1.5

  • Started the development of an entirely new version of RED by using Microsoft Visual C# (.NET 2.0)

1.4

  • Updated the readme and changed the license from GPL to LGPL
  • fixed some small issues

1.2

  • Fixed the gauge in the process window
  • implemented a second safety check to prevent deleting filled folders

1.1

  • renamed the program to RED (Remove empty directories)
  • made a new icon

1.0

  • changes some structure things, renamed functions, renamed variables
  • corrected code, fixed some issues...
  • optional logfile implemented
  • other minor changes
  • updated version history -> complete rewrite ;)

0.9

  • Added a readme, the licenses
  • Translated the readme into English

0.8

  • Cleaned the directories and sorted the files
  • Renamed some functions and variables, to make it look better

0.6 + 0.7

  • I learned about WinBinder (A native Windows binding for PHP) and converted the program to PHP with a Windows GUI using WinBinder

0.5

0.2 - 0.4

  • Minor changes
  • Added filters to exclude some folders like the recycler

0.1

  • I made a simple perl script to delete empty folders, I called it "DEF" (Delete Empty Folders)

Credits

Third-party components

Icon sources

  • Nuvola icons (GNU LGPL 2.1. license)
  • NuoveXT icons (GPL license)
  • famfamfam silk icons (Creative Commons Attribution license)
  • Coffee icon by Ivan Freaner
  • Ignore list icon taken from "Primo Icon Set" made by Webdesigner Depot
    • License: Free of charge for personal or commercial purposes

License

RED is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

remove-empty-directories's People

Contributors

gioccher avatar hxseven avatar jsytniak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

remove-empty-directories's Issues

command prompt parameters

Would it not be possible to make RED usable in a batch file, perhaps with command line parameters?

.NET6 x64 version

I've ported it to .NET6 and released a x64 version for anyone who looks for it: https://github.com/Symbai/RED2Core

@hxseven: I gave credits in the readme file. Still I respect you as the owner of this wonderful program. Please don't see this as "advertisment". I do not plan to do anything else with it. I just want to let people know .NET6 has a lot of performance improvements over .NET Framework so it might be useful for someone. Still if you wish you can delete this message.

[Feature request] Add setting to show icon in context menu

When we right click context menu on any folder, it would good if it showed the icon with the text
"Remove empty dirs"

This would make it more easier to find in the context menu, instead of text only.

Maybe a setting to enable this would be good,
and also an option to let us select the icon besides the default would be good.

need option to ignore infinite loop entries, and just delete the empty folders

on v2.2, using Windows 10 Pro 64bit.

It finds empty folders but also finds 'infinite loop detected' - what actually is this? when I open the folder where this is found, I can't see a symlink, so what else could it be?

At the end of the scan, I have a number of 'infinite loop detected', but the delete empty folders button is greyed out - why? Is it possible to tell the problem to exclude the infinite loop detected entries and just delete the empty folders. I looked in settings, and could not see an option for this.

tried v2.3 beta, but this seemed to hang, or didn't give clear indication on progress.

Folder deletion very slow

The scan for empty folders was pretty fast. It found 365 folders in a couple of seconds. When I started the deletion however, it only deleted about 2-3 folders per second. So it easily takes several minutes to delete a couple of hundred folders.
I haven't looked at the code, but shouldn't it take only several milliseconds to delete a folder or is there something special going on?

%temp%

%temp% as dir not supported?

Suggestion

Can you make it so instead of putting files into the recycling bin, you can make it put it somewhere where you can choose?

Directory ignore list not updated properly via context menu

If you add directories to the ignore list via the context menu, the entries will be added to the list (visible in GUI), but won't actually be used. Rescanning does not honor the additions and closing the app removes the entries completely. A workaround is manually modifying the text box after adding the ignore.

The problem is this piece of code:

private void proToolStripMenuItem_Click(object sender, EventArgs e)
    {
        if (this.tvFolders.SelectedNode == null) return;
        this.tcMain.SelectedIndex = 1;

        // TODO: Find a better way...
        this.btnDelete.Enabled = false;
        this.tbIgnoreFolders.AppendText("\r\n" + ((DirectoryInfo)this.tvFolders.SelectedNode.Tag).FullName);
    }

You're only adding the ignore to the text box, but the data binding is not updating the actual bound data. Didn't bother to look into the binding you did, I'm sure it's an easy fix for you ;)

Ignore list as checkboxes?

It would be nice if the ignore list were checkboxes instead of just a list, because sometimes I want to ignore certain patterns and other times I don't, but I still want them around because the syntax isn't easy to retype or remember.

AllDup''s filter list, for example:

image

Alternatively, it could be a plain text list, but allow items to be commented out.

Looking for beta testers for new release 2.3

Hi everyone!
I finally had the time to compile and package a new version of RED 😊
It includes recent community contributions and I also made quite a few changes, mostly regarding the user interface.
The most visible change is probably the separation of the settings tabs into three different tabs.
I did this because I thought that the old tab looked very crowded. Additionally, I wanted to add more info about the options and explanations. I hope the settings are more user friendly now.

I would be very happy if some of you, could try the new version and give me some feedback.
I also tested the installer and RED itself extensively on my computer and in different virtual machines (Win7/32 Bit, Win10/32 Bit & Win10/64 Bit). I also made some batch files to test different test cases (like special chars). You find that in the repo if you are interested.

You can download the beta version of the new release over here:
https://github.com/hxseven/Remove-Empty-Directories/releases/tag/2.3-beta.0

Hog on Vista

On my Windows Vista (x86) machine RED scans 15000 odd mixed content and empty folders just fine at first. During this time it uses a modest amount of the processor and grows in RAM at a reasonable rate. It grows to about 35 MB of RAM. Then I click 'Delete Folders'. RED starts deleting folders, but it also starts growing in RAM (it also makes hefty use of the processor for some reason). Eventually it eats through all the RAM it can and throws an out of memory error.

Allow only one RED instance

I got this request by email:

I find very useful your program and really appreciate your efforts.
I would like to point you one possible 'problem'.
I found it very confusing the fact that the program allows for multiple instances.
It may happen that I have minimised the running instance and simply start a new one, unaware or oblivious of the previous one being still active. That sometimes can give unexpected behaviour to the user.
I think that this kind of application is better limited to a single instance.
What do you think about this?
However, thanks always for your work.

I think that is a valid point. I will have a look on how complicated it is to implement this.
Does anybody have any arguments against this? I'm open for discussion :)

Exception when attempting to protect the root node in the treeview

Attempting to protect the root directory in the RED2 treeview could pass a NULL node to the ProtectNode method.

Fix: Check for NULL before processing in the ProtectNode function in TreeManager.cs (just like unprotectNode does)

I've fixed it in my local copy and have created a Pull Request if you want to merge it into your your master branch.

-- Robert 'NotBob' Bookerby

Almost Perfect

Tried it out and it did exactly what I wanted and needed.
In my experiment I deleted 340 directories.
Search was incredibly fast, deletion took longer.

In poking around I opened the log file and the app hung up.
Had to go to task manager to kill the process.

Processor Intel(R) Core(TM) i9-10850K CPU @ 3.60GHz 3.60 GHz
Installed RAM 32.0 GB (31.9 GB usable)
Device ID 0E755969-FD76-4119-8C68-4918F9F4FEF7
Product ID 00330-80000-00000-AA204
System type 64-bit operating system, x64-based processor
Edition Windows 10 Pro
Version 21H1
Installed on ‎5/‎19/‎2021
OS build 19043.1237
Experience Windows Feature Experience Pack 120.2212.3530.0
HTH
Mike

File name|ending|type|permission|size special character false positives

Dear Mr. John,

According to your disclaimer, I wish to inform you about a possible incomplete special character handling that may help to finally find the devastating issue of false positives getting deleted.

Urlaub Wörthersee 2013 216-84x147,5.tmp

was detected as empty but was not. This too was a false positive:

Asanger c2\C2 mit Maß\C3mit Maß

while these folders not:

Asanger c2[Entwickelt]
Asanger c

This may mean that is has to do with file names|endings|contents|sizes.

I send the folder in question without the big >25MB file in directly located in folder "Asanger c2" to you (but all your emails failed, even the johnj...preis...de)

LG,
Jan

x64 Version and Windows Store Distribution

First, I'm glad this tool is getting newfound attention! Thanks!

I just tried installing v2.2 and noticed it's x86 and required an older version of the .NET Framework installed. It would be nice to avoid that and install a 64-bit version instead.

Have you considered putting it on the Windows Store? I wonder if tools from Advanced Installer can make that happen.

Offer the ability to export the list of empty directories found

I am using this great tool in a specific context where I cannot remove the empty directories from the Windows machine where Remove-Empty-Directories is running.
The ability to export the list of discovered empty directories would really be useful.
It could be to the log file, to a specific file or the clipboard through a contextual command or using a command line parameter, as you prefer.
The format of such textual would be one full directory listed per line.

Thanks

add support for symlinks

This tool looks like exactly what I want, but doesn't currently support symlinks so it won't work for me. I have a directory where I have a large number of drives mounted, and would like to be able to scan all of those drives at once instead of selecting them one by one.

Behaviour for nonempty folders whose name contains a protected pattern, e.g. "Recycler"

I have protected the usual folder names, like "Recycler".
That means that if I scan my music collection, which includes ZZ Top's "Recycler" album, it shows up in blue.

Since the folder is nonempty, it should not be displayed at all.
Displaying it is actually even unwanted - then I have to check it manually to see that oh, I didn't accidentally (re)move the content.

I understand that for folders that lead to "unwanted" behaviour, like infinite loops I guess, then protection is a way to avoid it showing up altogether - that could make a cause for an ignore function that works like it does. But then in the very least, make it match exactly (wildcards supported) so that RECYCLER would be protected but ZZTopRecycler would not be.

difference with everything

2023-09-20 11_13_10-Find Files

everything childfilecount:0 == finds 241 folders
but RED finds 232


and btw, Enter button in path field - doesn't work

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.