Sponsored Content
Top Forums UNIX for Dummies Questions & Answers [SOLVED] Delete files and folders under given directory Post 302552387 by ramse8pc on Friday 2nd of September 2011 04:50:11 PM
Old 09-02-2011
[SOLVED] Delete files and folders under given directory

I have a requirement to delete the files and folders under a given directory.
my directory structure is like this..
HTML Code:
Data
|
A(Directory)
	|_PDF(Directory)----pdf files
	|_XML()Directory --xml files		
	|--files
|
B(Directory)
	|_PDF(Directory)----pdf files
	|_XML()Directory --xml files		
	|--files
|
C(Directory)
	|_PDF(Directory)----pdf files
	|_XML()Directory --xml files	
	|--files
	
|
n directories and sub directories
I need to delete the files and folders underneath A(Directory),B(Directory),C(Directory) ... N(Directory) and not the directories it self.
Directory should be there.Basically Data and underneath directories should remain. But all sub-directories should be empty.

i tried like this but it deletes all the directories and folders under given
directory
HTML Code:
find $folderPathTodelete -mindepth 1 -delete

Appreciate if anybody can help me with this.

Thanks
-Ramse

---------- Post updated at 04:50 PM ---------- Previous update was at 04:29 PM ----------

It's working when i changed mindepth to 2. :-)
Code:
find $folderPathTodelete -mindepth 2 -delete


Last edited by radoulov; 09-04-2011 at 11:03 AM.. Reason: Marked as solved.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

delete all folders/files and keep only the last 10 in a folder

Hi, I want to write a script that deletes all folders and keep the last 10 recent folders. I know the following: ls -ltr will sort the folders from old to recent. ls -ltr | awk '{print $9}' will list the folder names (with a blank line at the beginning) I want to get the 10th folder from... (3 Replies)
Discussion started by: melanie_pfefer
3 Replies

2. Shell Programming and Scripting

delete files and folders older than 3 days

find /basedirectory -type f -mtime +3 >> /tmp/tempfile find /basedirectory -type d -mtime +3 >> /tmp/tempfile mailx -s "List of removed files and folders" myemail@domain.com < /tmp/te mpfile rm /tmp/tempfile find /basedirectory -type f -mtime +3 -exec rm {} \; find /basedirectory -type d... (7 Replies)
Discussion started by: melanie_pfefer
7 Replies

3. Shell Programming and Scripting

Compare files in two folders and delete missing ones

I do not know much about shell scripting so I am at a loss here. If someone can help me, that would be great! I have two directories /dir1 /dir2 I need to delete all files from /dir1 and that does not have a correspondent file in /dir2. It should NOT check file suffixes in /dir2 . Why?... (20 Replies)
Discussion started by: kaah
20 Replies

4. UNIX for Dummies Questions & Answers

Delete folders and files in it - UNIX

I need to delete a folder and files in it of yesterdays and simply put this in cron. Folder name - "2010-03-2010" File name - "eprod_06_23.dmp" and "eprod_06_23.exp" Actually this folder and file is been created by a script which takes a backup of DB everyday.Thats why it creates folder and file... (3 Replies)
Discussion started by: j_panky
3 Replies

5. Shell Programming and Scripting

delete folders with no mpgs or nuv files

I need some help writing a simple script that will delete all subfolders that contain no mpg or nuv files, if they have anything else or are empty the folder should be deleted I got this far but I'm pretty hopeless foo=0 if then foo=1 fi if then foo=1 fi if then echo found... (9 Replies)
Discussion started by: mrplow
9 Replies

6. Shell Programming and Scripting

Loop folders, delete files, copy new ones

Folks, I am hopeful that you may be able to help me out with writing a script that can be run nightly (as cron?) to loop through all subfolders within the "/media" directory, delete all of the files in each of them, and then copy in all of the files from the "/home//sansa" directory to each of... (6 Replies)
Discussion started by: acraig
6 Replies

7. Shell Programming and Scripting

Delete multiple folders in a directory which are two weeks old

I need help. I have to delete multiple directories inside a directory that are two weeks old. Example: Today is July 09, 2012 Folder1 > folder1 (created June 4, 2012) -- should be deleted > folder2 (created June 2, 2012) -- should be deleted > folder3 (created... (4 Replies)
Discussion started by: jasperux
4 Replies

8. Shell Programming and Scripting

Copy the files in directory and sub folders as it is to another directory.

How to copy files from one directory to another directory with the subfolders copied. If i have folder1/sub1/sub2/* it needs to copy files to folder2/sub1/sub2/*. I do not want to create sub folders in folder2. Can copy command create them automatically? I tried cp -a and cp -R but did... (4 Replies)
Discussion started by: santosh2626
4 Replies

9. Shell Programming and Scripting

Script to delete folders and files from a prompt

Hi Everyone, I work for GE Money IVR as a DB analyst and the environment on which I work is Solaris 5.0 server and Oracle 11g. I got a project in which I have to clean up the folders and files which are not used in DB. I copied an existing script and edited it, dont know this is the... (5 Replies)
Discussion started by: habeeb506
5 Replies

10. Shell Programming and Scripting

How to delete all the files and folders inside all the directories except some specific directory?

hi, i have a requirement to delete all the files from all the directories except some specific directories like archive and log. for example: there are following directories such as A B C D Archive E Log F which contains some sub directories and files. The requirement is to delete all the... (7 Replies)
Discussion started by: Little
7 Replies
SCVIM(1)						      General Commands Manual							  SCVIM(1)

NAME
scvim_make_help - strip SuperCollider HTML help to text, for use with scvim SYNOPSIS
scvim_make_help [options] DESCRIPTION
This manual page documents briefly the scvim_make_help command. scvim_make_help is a script that strips SuperCollider HTML help to text format, for use with scvim. Users do NOT normally need to invoke it, since it is called by the main scvim script upon first run. The stripped files are placed in ~/.scvim by default, but this can be overridden by specifying SCVIM_CACHE_DIR environment variable. OPTIONS
A summary of options is included below. -s --source-dir directory Specify the soruce directory to search for HTML help files. -d --dest-dir directory The Destination Directory for the processed Help Files. -c --clean Clean the Destination Directory before building the helpfiles. -f --force Do not prompt to see if the user is sure about deleting files. -h --help Show summary of options. SEE ALSO
scvim(1) /usr/share/doc/supercollider-vim/README.scvim AUTHOR
scvim was written by Alex Norman <alex at x37v dot info>. This manual page was written by Dan Stowell <danstowell@users.sourceforge.net>, for the Ubuntu project (but may be used by others). Nov 18, 2008 SCVIM(1)
All times are GMT -4. The time now is 03:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy