How to delete 0byte files?

Heuveltje

Verified User
Joined
Nov 7, 2006
Messages
87
Location
Leek, NL
Hi all,

i have a webcam set up, it tranfers a picture every minute to a ftp server.
The connection is made via UMTS, sometimes file transport is corrupt and creates a jpg as 0byte file in the directory.
In the night, when transfers are stopped the server generates .flv files of all the .jpg s of that day. Done via cron and using ffmpeg.
However if there is only 1 .jpg file in the directory the creation of the movie fails.
So what i would like to do is have some lines in my cron that checks the .jpg's in the directory and deletes the 0byte .jpg files before they are tried for processing by ffmpeg.

Does any one have a solution for this? Ive searched around but cannot find any usefull script-lines for this. Maybe i use the wrong words in the search engines?
 
Use this code

Code:
find /home/username -size 0k -name *.jpg -exec rm {} \;

You can change the /home/username to the folder you want to search.
 
Thanx Chatwizrd, this works great!

However i find that in a cron you need to do fullpath commands:

Code:
/bin/find /home/username -size 0k -name *.jpg -exec /bin/rm {} \;
 
Back
Top