Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

HarryPot

macrumors 65816
Original poster
Sep 5, 2009
1,085
548
I'm trying to make a script that automatically delete files under 10mb in a folder.

Is this possible?


Thanks in advance.:)
 
Using the Unix shell. Use Terminal:

To print the files that will be caught:
Code:
find directory -maxdepth 1 -size -10M -type f -print

To actually delete them:
Code:
find directory -maxdepth 1 -size -10M -type f -delete

Replace "directory" with the directory name in both cases. That command will only delete the files in that directory. Take out the "-maxdepth 1" if you want it to recurse down all directories in that tree.
 
Ok, it seems that the code only works in Terminal, not in AppleScript.

Is there a similar code that works in AppleScript?
 
Ok, it seems that the code only works in Terminal, not in AppleScript.

Is there a similar code that works in AppleScript?

Well use some other script capable method like a bash script in combination with a cron job to do the automatic deletions by calling your script at per-determined times.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.