General approach:

# testing list all files that match
find /search/this/folder -iname "for*this*file*php" -type f

# delete all the listed files
find /search/this/folder -iname "for*this*file*php" -type f -delete

example:

Delete OSX Finder Files ._

# test
find . -iname "._*" -type f;
find . -iname "__MACOSX" -type f;

# delete
find . -iname "._*" -type f -delete;
find . -iname "__MACOSX" -type f -delete;

delete all Windows .DS_Store files

# testing list all files that match
find . -iname ".DS_Store" -type f

# delete all the listed files
find . -iname ".DS_Store" -type f -delete

delete all Thumbs.db and Thumbs.db:encryptable

# testing list all files that match
find . -iname "Thumbs.db" -type f;find / -iname "Thumbs.db:encryptable" -type f;
# delete all the listed files
find . -iname "Thumbs.db" -type f -delete;find / -iname "Thumbs.db:encryptable" -type f -delete;

delete files older than x days with subdirectories

type option for filtering results

find accepts the type option for selecting, for example, only files.

# delete only files
find /search/this/folder -type f -ctime +30 -exec rm -Rf {} \;

# delete files and directories
find /basedirectory -ctime +30 -exec rm -Rf {} \;

# qnap find does not know ctime and exec use mtime and a temp file
find /search/this/folder -type f -mtime +30 > /search/this/folder/files_to_delete.txt;rm $(
admin