No announcement yet.

deleting folders based on partial file names

  • Filter
  • Time
  • Show
Clear All
new posts

  • deleting folders based on partial file names

    Trying to figure out how to select folders that get created by a serverside media encoder. Files are moved to other servers, but empty folders stay behind. These need to be deleted from a large file tree that for the most part is always empty, waiting for users to drop files.

    We need to filter for empty folders ending on *_SS

    select right.all
    filter *_SS\
    delete right

    does not work

    is this even possible? I only see examples with extension-based filters. Can't do it based on time cutoff because some of the folders in the tree get added as users are added and may be new enough to get selected as well.

  • #2

    In the script, I would suggest having the filter line first. But first, check your filter text in the graphical interface. Copy and paste "*_SS\" into your Filter text box in the upper right corner of the screen (replacing *.*). Do the folders you expect to be visible the only visible items?

    Did you need additional logic to try and detect if they are empty, or do you want to just delete any folders that end with _SS\ on the right side?
    Aaron P Scooter Software


    • #3
      pasting the filter string into the GUI changes nothing - I still see either nothing (or the entire tree if I supress the filters). The comparison is between two identical trees on two servers, no files in any folder. First I want to delete right, when that is done, I can delete from the backup server the new orphan folders.

      There will be a cutoff filter as well - every 7 days folder content is deleted and then the folders need to be removed as well. Any of the folders ending on *_SS that are newer than 7 days can stay and will not be empty.

      Simply doing a select.all and a >7 day cutoff filter for the entire tree doesn't work because I need to retain the underlying folder structure (about 200 accounts, 3 sub folders each, and then in one of these there may be the *_SS folders created based on source file names they submit. we hold files 7 days, but then need to free up the drive space). I figure the easiest way to remove these folders is to filter by age and that partial name name.
      Last edited by pburke; 03-Aug-2011, 03:46 PM.


      • #4
        here's a sample tree of what I have to work with
            │   └───burke
            │   └───burke
        and what I want to do is delete the bottom two folders. There are over 200 of the folders called \burke in this example and the naming of the *_SS folders can be totally random up to the suffix that is always the same.


        • #5

          You'll need to include the parent folders in the filter as well. This can be done using the:
          filter in the Filter's textbox in the upper right toolbar. For more details on the syntax, go to the Session menu -> Session Settings, Name Filters tab, and click the '?' for the context help article. From there, you can click the "file masks" link.

          How does this filter work for you?
          Aaron P Scooter Software


          • #6

            Our Date filters only apply to file timestamps, and not the timestamp of a folder (which can change/update whenever anything inside of it is changed.)

            When we show Newer/Older status on a folder, that indicates that the files inside are newer or older. Our legend for coloring can be found in the View menu -> Legend. You can test date filters in the graphical interface as well, they are in the Session Settings -> Other Filters area, under the Date section.
            Aaron P Scooter Software


            • #7

              Does the:
              select empty.folders
              scripting command help with your current task? It is documented in the Help file -> Scripting Reference section, under the Select command.
              Aaron P Scooter Software


              • #8
                Entering the filter in "Session -> File Filters Include folders," it does take the string and shows it in the fitlers bar. Still, nothing changes, the folders do not show as selected (I suppose because they exist in the left side tree as well?)

                I tried the same in the script then and it delted every folder.

                log verbose append:C:\folder_cleanup.txt
                load "Y:\test" "F:\test"
                expand all

                filter "...\*_SS\"
                select right.empty.folders
                delete right
                it does the same if I filter after the select or if I select.all instead of the empty folders.

                this is version 2.5.3 and it is running on a 2008 server, if that makes a difference.

                maybe it is easier to delete the folders at the same time I delete the files in them? The problem is that I need to protect all the other folders, and a select.all will destroy the folder structure below.

                This is what I do to delete the content of those folders on both servers (the important part, and it works well, with the exception of leaving the *_SS folders behind)

                expand all

                select right.files
                filter cutoff:>7days
                delete right

                select right.newer.files right.diff.files right.orphan.files
                copy right->left
                select left.orphan.files
                delete left

                select left.diff.files left.orphan.files
                delete left


                • #9
                  did some more testing and it appears that it will delete the parent folders in the tree that ends on the folder names that match the filter and not the other tree branches. Still, that is not what I want. I just want to delete the folder that match the *_SS naming mask, but keep the entire parent folder structure in place.

                  I tried BC3 - same thing:

                  8/4/2011 1:10:54 PM  >> expand all
                  8/4/2011 1:10:54 PM  >> 
                  8/4/2011 1:10:54 PM  >> select right.empty.folders
                  8/4/2011 1:10:54 PM  >> filter "...\*_SS\"
                  8/4/2011 1:10:54 PM  >> delete right
                  8/4/2011 1:10:54 PM  Deleted F:\test\streaming_users_drops\HD\burke\BBB_1080P_25mbps_VBR_master_h264_SS
                  8/4/2011 1:10:54 PM  Deleted F:\test\streaming_users_drops\HD\burke\ED_1080P_SS
                  8/4/2011 1:10:54 PM  Deleted F:\test\streaming_users_drops\HD\burke
                  8/4/2011 1:10:54 PM  Deleted F:\test\streaming_users_drops\HD
                  8/4/2011 1:10:54 PM  Successfully deleted 4 items.  Completed in 0.02 seconds.
                  8/4/2011 1:10:54 PM  >> 
                  8/4/2011 1:10:54 PM  Script completed in 0.08 seconds
                  and when I drop the ...\ from the filter, nothing gets deleted.

                  8/4/2011 1:13:57 PM  >> select right.empty.folders
                  8/4/2011 1:13:57 PM  >> filter *_SS\
                  8/4/2011 1:13:57 PM  >> delete right
                  8/4/2011 1:13:57 PM  >> 
                  8/4/2011 1:13:57 PM  Script completed in 0.06 seconds


                  • #10
                    so I made it work by putting dummy files in to all the folders in the tree that I need to retain, but that's really a last ditch solution.


                    • #11
                      There isn't a good way to tackle this in BC3. If you change your initial pass (deleting the files) to filter and only show ...\*_SS\*.* files and also have the date cutoff, you can delete only files in the _SS folders. At which point, you could then script the deletion of the empty folders, but this would still include any parent empty folders that were naturally empty. Would any folders be empty before you performed any automated script deleting?
                      Aaron P Scooter Software