[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. :-)
Last edited by radoulov; 09-04-2011 at 11:03 AM..
Reason: Marked as solved.
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)
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)
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)
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)
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)
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)
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)
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)
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
LEARN ABOUT OSF1
cddrec
cddrec(1) General Commands Manual cddrec(1)NAME
cddrec - Read Directory Record from CD-ROM directory
SYNOPSIS
/usr/bin/cddrec [-s number] [-b] file
OPTIONS
Specifies the File Section for which the Directory Record is to be read. The numbering starts with one and can be any whole number. If
this option is not used, the last file section of the named file is assumed. Copies the entire Directory Record from a CD-ROM in binary
format to standard output. Names a file within the CD-ROM file hierarchy of a mounted CD-ROM File System.
DESCRIPTION
The cddrec command reads the Directory Record associated with a file or directory on a mounted CD-ROM and lists its contents on standard
output.
The output is formatted in a table that contains the name of each field of the Directory Record and the corresponding contents of the entry
as recorded on the CD-ROM. Note that the System Use field is not listed because it may contain non-printable characters.
Users must have read permission for file in order to execute the command.
EXIT STATUS
The following exit values are returned: The command was successful. The named file was not found, or was not within the CD-ROM hierarchy,
or access permission was denied. The File Section indicated by file does not exist.
SEE ALSO
Functions: cd_cdrec(3), cd_drec(3)cddrec(1)