Folder permissions to delete

I am using the below command to delete files from directories and subdirectories

find /test/abc/xyx -type f -mtime +7 -exec rm -f {} \;

there are some subfolders in xyx for which i don't have permission to delete.

Is there a way i can check the permission of the folder first and then delete the files.
Thanks in advance

find can't react differently depending on what folder it's inside. You could make a big complicated program to find writable directories and delete every file inside them, or just ignore the errors with 2> /dev/null.

There are lots of methods of finding things with certain permissions with find, but what functions you have depends on your system. What is your system? What is your shell?

i am new to unix...trying to learn things...

system is linux and shell ksh by default..

Just so that I am clear, are you trying to delete folders? I am asking because rm -f won't work on folders.

If you have GNU find that makes things a lot simpler, it supports -maxdepth to prevent recursion.

# Find every writable directory inside /path/to/base
find /path/to/base -type d -writable |
while read DIR
do
        # Print all files inside writable directories.
        find "$DIR" -mindepth 1 -maxdepth 1 -type f

        # feed the list into xargs, which turns it into rm -f file1 file2 file3 ...
done | xargs echo rm -f

Remove the 'echo' from xargs once you've tested that it really does what you want.