Delete files based on modification date

Hi,
The goal is to delete all files in a specified folder where the modification date is greater than 35 days.

The actual deleting has to be done via “do shell script” although the list of modified files can surely be applescript (it will be deleting files from a mounted volume). I found a post that seemed like it would work but I was unable to get it to function properly and I can’t seem to find any new code to work off of.

The path to the folder it will look at will be a variable we’ll call “modifiedFiles” for simplicities sake.

Could someone please help me out with this?
Thanks!

Using AppleScript here is an example of finding all the files whose modification date is greater than 35 days

set theFolder to choose folder
set theDate to (current date) - (35 * days)

tell application "Finder"
	try
		set files2delete to (every file of entire contents of theFolder whose modification date is less than theDate) as alias list
	on error
		set files2delete to (every file of entire contents of theFolder whose modification date is less than theDate) as alias as list
	end try
end tell

And the shell equivalent would be like this

set theFolder to choose folder
set files2delete to paragraphs of (do shell script "find " & quoted form of POSIX path of theFolder & " -type f -mtime +34")

Once you have your lists you just need to pass it through to a delete routine, or if you are using the find command you could also call a inline exec and do the delete there.

Awesome. After a bit of customization, it worked great.

Thanks for your help James!