Finding non-jpg files

Carl waldbie at verizon.net
Tue Aug 22 23:02:32 UTC 2006


On Tuesday 22 August 2006 5:00 pm, Dotan Cohen wrote:
> I have a large recursive directory of pictures that was once in a
> windows machine. Now that I have copied it to my linux box, I need to
> remove all the files that are NOT jpgs. How can I list all the files
> in a recursive directory that don't end in ".jpg" or ".jpeg"? A shell
> script would be nice, but even a gui program would help. Thanks.
>
> Dotan Cohen
> http://what-is-what.com
>
> 23
To see the list:

$ find . \( ! -iname '*.jpg' -print0 \) \( ! -iname '*.jpeg' -print0 \) | 
xargs --null printf "%s\n" | less

To remove the files (make sure you run this in the folder you want to clean!  
Backup the folder first, if possible!) :

$ find . \( ! -iname '*.jpg' -print0 \) \( ! -iname '*.jpeg' -print0 \) | 
xargs --null rm -f

Carl W.




More information about the kubuntu-users mailing list