Announcement

Collapse
No announcement yet.

Option to delete empty folders?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Option to delete empty folders?

    Assume I compare two directory trees.

    In the result page I delete a couple of files and delete them.

    In such a situation I would like to have an option which tells BC:
    If the just deleted file was the only/last file in the directory then delete the wrapping (now empty) directory as well.

    Is there such an option?

    Peter

  • #2
    Not exactly as an action performed automatically after deleting files.

    You can delete empty directories by using together the Display Filters "Show None" (file) & "Always Show Folders". Selecting all folders you want (collapsed or expanded) and selecting the Delete-Action with the "Include hidden items in operation"-option UNCHECKED will only delete empty folders, although all selected folders and their subfolders are counted in the preview (must show: 0 file(s)/n folder(s)/0 bytes).

    I tested this on a backup drive showing above 1k folders and only 27 empty folders were deleted.

    Greetings Lutz

    Comment


    • #3
      Hmm, how do I setup the Display Filters "Show None" (file) & "Always Show Folders"?

      I do not found them neither in "View" menu nor in "Options" dialog

      Comment


      • #4
        Hello Peter!

        From an open Folder Compare session choose Tools/Customize Commands and search for "none". Then check "Show command in menu" and/or "Show command on toolbar".

        "Always Show Folders" should be visible by default in the View-menu and on the Display Filters toolbar as "Compare Files and Folder Structure" button dropdown list. If not you can enable this command like "Show None".

        Greetings Lutz
        Last edited by Lutz; 15-Feb-2011, 02:59 PM. Reason: changed "Always Show Folders" access description

        Comment


        • #5
          Originally posted by Lutz View Post
          Hello Peter!

          From an open Folder Compare session choose Tools/Customize Commands and search for "none". Then check "Show command in menu" and/or "Show command on toolbar".

          "Always Show Folders" should be visible by default in the View-menu and on the Display Filters toolbar as "Compare Files and Folder Structure" button dropdown list. If not you can enable this command like "Show None".

          Greetings Lutz
          Hello Lutz,

          I tried out your suggestion.

          When I click the "None" icon on the toolbar then only folders are shown which are empty (=ok) but only exist on one side of the comparison table.

          I would like to find ALL empty folders even if the exist on both dir trees (left and right) or only on one side.

          Ok, I admit. It is not really a "comparison" feature but useful anyway.

          How can I achieve this?
          Maybe such a one-click specialized function should be included in the next release.

          Peter

          Comment


          • #6
            Hello,

            Try this, from default settings: *.* filter and Show All.
            1) Enable Compare Files Only (instead of Always Show Folders or Compare Files and Folder Structure).
            2) View menu -> Expand All
            *All empty folders will disappear from view. This should be the only items that disappear.
            3) Select All, then right click and Exclude.
            *This will exclude everything that was visible.
            4) Switch back to Always Show Folders

            How does that work for you?
            Aaron P Scooter Software

            Comment


            • #7
              Hi Peter,

              with "Always Show Folders" ALL folders on both sides have to be displayed (not only empty), please check it again.
              I can't imagine how you got BC to show only 0 byte folders, please provide a screenshot.

              I tried again with my two (a little different) backup drives using no filter. After comparing both drives all folders on left and right are visible with their space occupied. There is only one orphan subfolder on root level (blue colored).
              If I now select all top level folders (after Collapse All) and call Actions/Delete the preview shows the selected folders (26567/25766) and 0 file(s)/0 bytes on both sides with the hint "Folders with hidden items will not be deleted."

              Greetings Lutz

              Comment


              • #8
                Script option for 'Include hidden items in operation'

                I have a folder comparison problem that I hope someone can enlighten me about.

                The folders I am comparing contain some 'empty' folders and in the GUI are highlighted as orphans, together with some identical or different folders.

                I am using a filter to exclude '.metadata' folders and their contents.

                If I select only 'orphans' and click 'delete' I am given the option to 'Include hidden items in operation' - i.e. include the filtered-out folders/files.

                This works great and allows me to remove these orphan empty(ish) directories. Other directories also contain files (and contain the filtered-out folders/files).

                How can I do this with a script?

                Comment


                • #9
                  Hello,

                  Do you always want to delete the hidden items? You can enable that option as the default in the Tools menu -> Options dialog, Folder Views, Confirmations: "Include hidden items by default".
                  Aaron P Scooter Software

                  Comment


                  • #10
                    Originally posted by Aaron View Post
                    Hello,

                    Try this, from default settings: *.* filter and Show All.
                    1) Enable Compare Files Only (instead of Always Show Folders or Compare Files and Folder Structure).
                    2) View menu -> Expand All
                    *All empty folders will disappear from view. This should be the only items that disappear.
                    3) Select All, then right click and Exclude.
                    *This will exclude everything that was visible.
                    4) Switch back to Always Show Folders

                    How does that work for you?
                    Sounds promising, Aaron.
                    I have this problem in a big way ... deleting empty folders in very deep directory structures.

                    What I was looking for is the equivalent of a unix "find" command options:

                    find . -type d -empty | xargs rmdir # remove empty directories

                    The technique you provided would require bc3 to hide thousands of files.

                    The above works in Linux and Cygwin, and many enlightened unix platforms.

                    If the directory was empty because it had zero-byte entries in it,
                    then you use " rm -fr " ( remove force recursively ) option.
                    Last edited by dickdunbar; 13-Jan-2012, 01:27 PM.

                    Comment


                    • #11
                      Dick, did you have a question? Are you trying to delete empty folders on systems that don't have Cygwin installed, using just BC? If so, another approach, which works with BC2 as well is:

                      1) Select Tools->Save Snapshot.
                      2) Save a snapshot of either base folder with all of the "Include" checkboxes unchecked (except "Items excluded by file filters", if you have any active).
                      3) Double click the snapshot in Explorer to load a comparison against the original folder.
                      4) Use the Actions->Synchronize->Mirror to Left/Right (target the original folder) command.

                      The saved snapshot won't have any of the empty folders (since that option wasn't checked). That means as long as the original folder hasn't changed, synching will delete those empty folders and nothing else. It has the advantage that it shows exactly what it's going to delete, so you don't have to guess that it's doing the right thing.
                      ZoŽ P Scooter Software

                      Comment

                      Working...
                      X