Finding Hidden files and protecting the folder containing hidden files from deletion

Hi. I have a script which is deleting files with a particular extension and older than 45 days.The code is:
find <path> -name "<filename_pattern>" -mtime +45 -exec rm {} \;

But the problem is that some important files are also getting deleted.To prevent this I have decide to make a dummy hidden file in such folders which are not to be considered when this script is run.

Is this the right way to achieve the desired result???

If yes, then how can I do this??

If not, then what should be the ideal way??

Please.I need the solution urgently..

Thanx.

Hi,

use grep -v option before u run rm command

find arg|grep -v pat -exec rm {} \;

regards
Subbu Malepati

However I still want to delete the directory.

nov_user

Can you show a sample of the <filename_pattern> and that of the important files.

you can use negation

# find /path -type f  -name "file_pattern_to_delete" ! -name "file_not_to_delete"   .....