Sponsored Content
Top Forums Shell Programming and Scripting Removing folders - hierarchical stored Post 302807993 by princetd001 on Thursday 16th of May 2013 03:04:48 AM
Old 05-16-2013
but my folder structure is
Code:
 
 
2001-2100/01-12/01-30/files

If we remove dates in removal process based on 541 criteria , 1-30 , then automatcally month folder should be removed,

in removal process, if there is no month folder, then year folder must be removed automatically

Thanks,

---------- Post updated at 06:47 PM ---------- Previous update was at 06:02 PM ----------

I changed retention criteria from 541 days to 455 days , we need to remove all parent and children folders and files inside date folders from from feb 15, 2012 to older dates . but 2012 and feb month folder will be there untill we hit 455 lmit on feb 01 ,2012.

so if we calculate , we need to remove all files in 2010/01-12/01-31 folders and 2011/01-12/01-31 foders and in the year 2012, we will keep till feb 03 and 15 days of files in feb to make it 455 days


---------- Post updated at 06:57 PM ---------- Previous update was at 06:47 PM ----------

it should consider backward when counting number of dates, 2013/may, 2013/apr,2013/mar,2013/feb,2013/jan , 2012/dec, 2012/nov, 2012/oct, 2012/sept,2012/aug,2012/jul, 2012/jun, 2012/may,2012/apr,2012/mar,2012/feb , then keep files inside of folder date from 28 to 13 to retain 455 days of files. file exist only in date folders.

---------- Post updated 05-16-13 at 02:04 AM ---------- Previous update was 05-15-13 at 06:57 PM ----------

I want to add a few things to addition to above mentioned points. This might help you understand my requirement more clearly

Designing criteria:
1. its desined to hold files in hierarchical folder structure of year/months/dates/files
2. root folder contain year folders
3. Year folder contains month folders
4. month folder contains date folders
5. date folders contain data files
6. date folder contains only the data files that particular date produced.
7. remove all data files which is older than 455 days
8. remove all date folders which is older than 455 days
9. remove all months folder if they do not contain any date folders due to 455 days removal process
10.remove all year folders if they do not contain any months folders due to above process
11. script should consider from 2000 to 2100 years or dynamic
it should be removed as the following direction, for example considering today is may 15 2013,
then folder 2013/05/15 to 2012/02/29-14 should be retained and rest of the olders date, months and years folders
should be removed

Code:
 
 
YEAR MONTH DAY
2013 5 15
2013 4 30
2013 3 31
2013 2 28
2013 1 31
2012 12 31
2012 11 30
2012 10 31
2012 9 30
2012 8 31
2012 7 31
2012 6 30
2012 5 31
2012 4 30
2012 3 31
2012 2 29-14
=======================================================
2012 2 1-14
2012 1 31
2011 12 31
2011 11 30
2011 10 31
2011 9 30
2011 8 31
2011 7 31
2011 6 30
2011 5 31
2011 4 30
2011 3 31
2011 2 28
2011 1 31
2010 12 31
2010 11 30
2010 10 31
2010 9 30
2010 8 31
2010 7 31

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Removing old folders

All Please help me to remove old files. For example /usr/exp/ - inside this Apr 02 - dir02 Apr 03 - dir03 Apr 04 - dir04 Apr 05 - dir05 Apr 06 - dir06 Apr 07 - dir07 Apr 03 - file03 I want to delete all the folders 2 days before created.Not the fil03 even though it is 2 days old. ... (1 Reply)
Discussion started by: DeepakXavier
1 Replies

2. UNIX for Dummies Questions & Answers

Removing empty folders using 'find'

Hey there! I try to use 'find' to remove empty directories like this: find . -depth -type d -empty -exec rm -rf {} ';' It works just fine, but there are some directories i want to exclude. So i tried to do sth like this: find . -depth -type d -empty -exec grep -v "not this one please" -exec... (5 Replies)
Discussion started by: deTTo
5 Replies

3. Shell Programming and Scripting

Help needed removing two top level folders from path

Hi, I am trying to use either awk or sed to drop the first two folders in a path. So if I had path /folder1/folder2/folder3/folder4.... I need to drop folder1&2, so the new path would be /folder3/folder4... If folder1 and folder2 were the same all the time, this would be easy. But... (4 Replies)
Discussion started by: robertinohio
4 Replies

4. Red Hat

how to remove inner files without removing child folders

Hi, I want to write a command to remove all the files from a folder and inner child folder without removing the child folders of parent folder. like I have folder like this... folder a/b/c file a/test.sql file a/b/test2.txt file a/b/c/temp.jpeg now I want to remove all... (2 Replies)
Discussion started by: mkashif
2 Replies

5. Shell Programming and Scripting

how to remove inner files without removing child folders

Hi, I want to write a command to remove all the files from a folder and inner child folder without removing the child folders of parent folder. like I have folder like this... Code: folder a/b/c file a/test.sql file a/b/test2.txt file a/b/c/temp.jpeg now I want to remove... (5 Replies)
Discussion started by: mkashif
5 Replies

6. UNIX for Dummies Questions & Answers

Removing empty folders

Hello, I have a folder that contains all my music. Recently, I started using a different media player, and I let it manage my music folder. It has sorted all my music neatly in folders by artist and album. However, all the old folders that the songs used to be in are still there, yet they are... (2 Replies)
Discussion started by: emveedee
2 Replies

7. UNIX for Dummies Questions & Answers

Removing Extra Folders From a TAR

I use an extremely simple TAR function for files at work and I have a question about cleaning them up. My command is TAR -cvf ExampleTarName.tar then the folder I wish to TAR. When my TAR finishes and I double click it to check it unarchived beautifully (I don't do this with every file, duh)... (5 Replies)
Discussion started by: Dogtown24
5 Replies

8. Shell Programming and Scripting

Removing folders with specific name/part

Hi, I need a way to remove all folders that contain "Quick" in their names in a directory called /var/tmp... However all attemps I have tried won't work. :wall: I so far tried find /var/tmp -type d -name "Quick" | sudo xargs rm -rf find . -name "Quicklook" -exec rm -rf {} \; find .... (2 Replies)
Discussion started by: pasc
2 Replies

9. Shell Programming and Scripting

Removing md5sum lines stored in text file

Hello. I'm writing a script where every file you create will generate a md5sum and store it into a text file. Say I create 2 files, it'll look like this in the text file: d41d8cd98f00b204e9800998ecf8427e /helloworld/saystheman d41d8cd98f00b204e9800998ecf8427e /helloworld/test I... (3 Replies)
Discussion started by: batarangs_
3 Replies

10. Shell Programming and Scripting

Recursivly rename folders removing characters as required

HI guys here's hoping some on pout the can help I have a large library of epub and mobi file creates some what by calibre. Output of tree listing below I would like to recursively rename the directories removing the brackets and numbers I have been scratching my head over... (4 Replies)
Discussion started by: dunryc
4 Replies
folders(1)						      General Commands Manual							folders(1)

NAME
folders - list folders and contents (only available within the message handling system, mh) SYNOPSIS
folders [+folder] [msg] [options] OPTIONS
Lists only the name of folders, with no additional information. This is faster because the folders need not be read. Prints a list of the valid options to this command. Lists the contents of the folder-stack. No +folder argument is allowed with this option. Re-numbers mes- sages in the folders. Messages are re-numbered sequentially, and any gaps in the numbering are removed. The default operation is -nopack, which does not change the numbering in the folder. Discards the top of the folder-stack, after setting the current folder to that value. No +folder argument is allowed with this option. This corresponds to the popd operation in the C-shell; see csh(1). The -push and -pop options are mutually exclusive: the last occurrence of either one overrides any previous occurrence of the other. Pushes the current folder onto the folder-stack, and makes the +folder argument into the current folder. If +folder is not given, the current folder and the top of the folder-stack are exchanged. This corresponds to the pushd operation in the C-shell; see csh(1). The -push switch and the -pop switch are mutually exclusive: the last occurrence of either one overrides any previous occurrence of the other. Lists folders recur- sively. Information on each folder is displayed, followed by information on any sub-folders which it contains. Displays only the total number of messages and folders in your Mail directory. This option does not print any information about individual folders. It can be sup- pressed using the -nototal option. The defaults for folders are: +folder defaults to all msg defaults to none -nofast -noheader -nototal -nopack -norecurse DESCRIPTION
The folders command displays the names of your folders and the number of messages that they each contain. The folders command displays a list of all the folders in your Mail directory. The folders are sorted alphabetically, each on its own line. This is illustrated in the following example: Folder # of messages ( range ); cur msg (other files) V2.3 has 3 messages ( 1- 3). adrian has 20 messages ( 1- 20); cur= 2. brian has 16 messages ( 1- 16). chris has 12 messages ( 1- 12). copylog has 242 messages ( 1- 242); cur= 225. inbox+ has 73 messages ( 1- 127); cur= 127. int has 4 messages ( 1- 4); cur= 2 (others). jack has 17 messages ( 1- 17); cur= 17. TOTAL= 387 messages in 8 folders. The plus sign (+) after inbox indicates that it is the current folder. The information about the int folder includes the term (others). This indicates that the folder int contains files which are not messages. These files may be either sub-folders, or files that do not belong under the MH file naming scheme. The folders command is identical to the effect of using the -all option to the folder command. If you use folders with the +folder argument, it will display all the subfolders within the named folder. as shown in the following exam- ple: % folders +test Folder # of messages ( range ); cur msg (other files) test+ has 18 messages ( 1- 18); (others). test/testone has 1 message ( 1- 1). test/testtwo has no messages. TOTAL= 19 messages in 3 folders. See refile(1) for more details of sub-folders. RESTRICTIONS
MH does not allow you to have more than 100 folders at any level in your Mail directory. PROFILE COMPONENTS
Path: To determine your MH directory Folder-Protect: To set protections when creating a new folder Folder-Stack: To determine the folder stack lsproc: Program to list the contents of a folder FILES
The user profile. SEE ALSO
csh(1), folder(1), refile(1), mhpath(1) folders(1)
All times are GMT -4. The time now is 07:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy