Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to remove all the .jpg files from my Music folder in order to save room. My Music folder contains subfolders, and I would like to know if there is a command to remove all the .jpg files from all these folders regardless of their level. Thanks for your help!

share|improve this question
add comment

3 Answers 3

up vote 2 down vote accepted

The easiest way (if you are using Ubuntu Desktop):

Go to your Music folder in Nautilus, press Ctrl+F and search for .jpg.

enter image description here & then delete it


You can also change the location and you can make your search more specific.

enter image description here


Updated

Be More specific after searching .jpg Clicking on green button Select File type Picture & then remove jpg from search only . dot & then reload as shown in pic below

What it does it will search Picture file like .jpg .png .gif & all other file which are in Picture Format

enter image description here

share|improve this answer
    
even better :) :) –  Rinzwind Feb 16 '12 at 18:34
add comment

A quick and clean solution for the command line would be

cd <dir>
find . -type f -iname \*.jpg -delete
  • -iname makes the search case insensitiv.
  • -type f tells find only to look for files.
  • -delete tells find to delete/remove all files found.

I recommend running the command without -delete first to get a list of the files that will be removed when -delete is included in the command. This way a small typo won't delete anything you didn't intend to.

For more information on how to use find and what it can do see man find

Note that find will not produce any output when -delete is used.

share|improve this answer
1  
+1 the only sensible answer –  knittl Feb 16 '12 at 19:21
    
Strange ...Tested on 11.04. DOES NOT WORK TO REMOVE FILES OR DIRECTORIES –  Ringtail Feb 16 '12 at 19:58
    
Strange indeed. Works on 11.10 and countless other distributions and versions of linux I've been running over the years. –  Zoke Feb 16 '12 at 20:01
    
I will need to proof this again. Not to say I've never been wrong.... –  Ringtail Feb 17 '12 at 0:48
    
This is the real answer –  eburgos Dec 29 '13 at 15:45
add comment

This should do it

sudo rm -rf -d ~/Music/*.JPG

which will remove all .JPG files within the Music folder.

share|improve this answer
    
This will not remove files from subfolders … –  knittl Feb 16 '12 at 19:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.