I need to delete all files smaller than 13MB in /media/motion AND all files with the same filename with an extra extension appended to it (that are all much smaller than 13MB) so I append '*' to the find result.

Files are like this:


I want to delete all .mp4 files that are less than 13MB AND the corresponding .mp4.thumb file (which are all very small)

I've tried two methods. Echoing the commands and running them works, but running the script does not:

/usr/bin/find /media/motion -name \"*.mp4\" -size -13M -exec rm -f {}\\* \\\;  

I get find: missing argument to 'exec'

I also tried:

/usr/bin/find /media/motion -name "*.mp4" -size -13M -print | xargs printf -- '%s \* \n' | xargs -0 rm -f

This results in no output.

1 Answer 1


If your didn't change the default crontab PATH (/usr/bin:/bin), then this should work in your shell and crontab:

find /media/motion -type f -name '*.mp4' -size -13M -exec sh -c 'for f; do rm "$f"*; done' sh {} +

This loops over the files using a shell script and expands * to the expected files.

Add -f to rm if you need it.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .