Buddy,
Having a properties file is a good option. U can use a loop to work on each directory individually. Loop it until it reaches the last directory. Inside the loop, do the following things:
1. Extract the period from the properties file in some variable. This can be done using grep command to search the directory name and then using cut command.
2. Check whether the directory is period times older. This can be done using find command with the option "mtime". Find command will display the list of files if the directory is older by period no. of days.
if[! -z `find "$file" -mtime +$period`];then
rm -r $file
fi
3. Remove the files if it satisfies the "if condition" .
4. Continue the same for all the directories.
5. I think you should take care of files directly under archive separately. Follow the same metod of checking whether the files are older by default time or not. If yes then delete them.
This is just an algorithm to solve the problem. Please revert back in case of any issues.
|