[WBEL-users] File deletion

Kirby C. Bohling kbohling@birddog.com
Wed Jan 19 23:03:43 CST 2005


On Wed, Jan 19, 2005 at 10:42:42PM +0000, Francies Moore wrote:
> Hi everyone
> 
> I have to somehow or other clean out a filesystem in order to start 
> again for this year.
> 
> These folders are a main folder for a Branch Office, with nested 
> subfolders for various safety test certificates that have to be scanned 
> and stored.  There are about 500 of the main Branch Office folders!
> 
> What I need to do is to remove the files but leave the directories intact.
> 
> Is it possible to use a script to do this?  If so, how?  I realise rm 
> -rf removes subdirectories as well as files!
> 
> The files are kept on a Windows box but I have copied them over to one 
> of my WBEL servers because I could not imagine any way of doing this in 
> Windows.
> 
> I realise this is not a WBEL issue as such but any help would be 
> appreciated.

cp -a /path/to/source /backup/copy/

# Use this to see everything you are about to delete:
find /path/to/source \! -type d -print

# Use this to actually delete it:
find /path/to/source \! -type d -exec rm {} \; -print

Oh, and if this breaks, you get to keep the pieces.  I'd test this
before I ran it, but it's my off the cuff way I'd do it.

One alternative is rather then this:
find /path/to/source \! -type d -print

you could use this:
find /path/to/source -type f -print

Not sure how "find" treats directories, files, and softlinks, or if
those are a problem in your situation.

(There are about a half dozen other ways to solve this problem, let
me know if this doesn't work, I can dream up more ways to do this).

	Thanks,
		Kirby




More information about the Whitebox-users mailing list