removing one file type from a large file collection(solved)

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read this

removing one file type from a large file collection(solved)

Postby psyodin on Sun May 11, 2008 8:02 pm

hello. i have large music collection and would like to remove all the jpeg files (ie cover, file, etc) that i have accumulated over time. so my plan would be to search my music file for any jpegs and delete them. i assume this is possible however the HOW is eluding me. i have tried the tracker search tool and the search tool in the file management program but either they dont work as i assume they should or im not using them properly. any help would be appreciated.


linux mint darnya with gnome desktop

good day
Last edited by psyodin on Mon May 12, 2008 2:28 am, edited 1 time in total.
User avatar
psyodin
Level 1
Level 1
 
Posts: 8
Joined: Tue Nov 13, 2007 12:16 am

Linux Mint is funded by ads and donations.
 

Re: removing one file type from a large file collection

Postby Fred on Sun May 11, 2008 8:28 pm

psyodin,

You can do this from the command line pretty easily. Open a terminal and change the directory to the one that holds your jpeg files.

cd /home/fred/Music

To remove all the jpeg files in that directory type:

rm -v *.jpeg

They will be gone. You can not recover them once you press enter. :-)

This of course can be used to delete other file types too, by changing the *.jpeg to *.mp3 as an example.

Fred
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: removing one file type from a large file collection

Postby psyodin on Sun May 11, 2008 8:54 pm

thank you for the help

when i tried that i get:

rm: cannot remove `*.jpeg': No such file or directory


now i have folders inside myputer@myputer:~$ cd /home/myputer/Music

for example /home/myputer/Music/A-I/Alice in Chains/Dirt/Folder.jpg

perhaps that is the problem but im hoping to avoid opening each folder or change directory to each folder to delete the jpeg files
User avatar
psyodin
Level 1
Level 1
 
Posts: 8
Joined: Tue Nov 13, 2007 12:16 am

Re: removing one file type from a large file collection

Postby Fred on Sun May 11, 2008 10:33 pm

psyodin,

Sorry I went to dinner.

Didn't realize your files weren't in one directory. try this in a terminal:

find . -name \*.jpeg | xargs rm

Fred
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: removing one file type from a large file collection

Postby Lysias on Sun May 11, 2008 10:44 pm

This could be of help as well

Code: Select all
find . -type f -name "*.jpeg" -exec rm -f {} \;
User avatar
Lysias
Level 1
Level 1
 
Posts: 27
Joined: Sun May 04, 2008 6:32 pm

Re: removing one file type from a large file collection

Postby Fred on Sun May 11, 2008 10:55 pm

Lysias,

This is workable too. The only thing about your approach is that the rm command is limited in the amount of data it can handle at one time. I got the impression he had a lot to delete. Don't know if it would be enough to cause an error or not.

Using a pipe and the xargs command breaks it up into multiple small chunks that rm may find easier to deal with.

Not throwing rocks. You idea will work just fine as long as he doesn't have too much data to deal with. :-)

Fred
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: removing one file type from a large file collection

Postby Lysias on Sun May 11, 2008 11:41 pm

Yes indeed you are right fred.!
It's the shell that might actually fail as the argument list is being instantiated because the list could get too large.But i figured the amount of files psyodin wants to delete wouldn't be sufficient for something like that to happen so I posted this as an alternate route of doing the same thing.

Psyodin you are better of sticking with fred's suggestion so you won't be running into any possible problems.!

Sorry if I simply added noise :oops:
User avatar
Lysias
Level 1
Level 1
 
Posts: 27
Joined: Sun May 04, 2008 6:32 pm

Re: removing one file type from a large file collection

Postby Fred on Sun May 11, 2008 11:47 pm

Lysias,

No need to be sorry sir. Your suggestion was a good one. I just had no idea how much data he was playing with, that's why I did it like that. :-)

That's whats nice about linux. There are always multiple ways of getting things done.

Please feel free to chime in on my instructions if you see something I am doing wrong, or a better way. It won't offend me, I am always willing to learn a better way. :-)

Fred
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: removing one file type from a large file collection

Postby Lysias on Sun May 11, 2008 11:57 pm

Indeed linux is all about choice in the end it has been said over and over again.

Same on my side dear Fred.Always willing to learn. :)
User avatar
Lysias
Level 1
Level 1
 
Posts: 27
Joined: Sun May 04, 2008 6:32 pm

Re: removing one file type from a large file collection

Postby psyodin on Mon May 12, 2008 1:33 am

when i try find . -name \*.jpeg | xargs rm
i get rm: missing operand
Try `rm --help' for more information.

i looked at help and put find . -name \*.jpeg | xargs rm -- *.jpeg foo

result rm: cannot remove `*.jpeg': No such file or directory


and find . -name \*.jpeg | xargs rm -v
result rm: missing operand

and with -f same result

when i try find . -type f -name "*.jpeg" -exec rm -f {} \;

result is nothing as far as can tell...files still there

i did try both under root and normal terminals and tried .jpeg and .jpg in the command lines

i very much appreciate the help proved thusfar. much obliged. i think the solutions provided thusfar are close.

good day
Last edited by psyodin on Mon May 12, 2008 1:47 am, edited 1 time in total.
User avatar
psyodin
Level 1
Level 1
 
Posts: 8
Joined: Tue Nov 13, 2007 12:16 am

Re: removing one file type from a large file collection

Postby Fred on Mon May 12, 2008 1:40 am

psyodin,

I wouldn't think you would need it but put this in:

find . -name \*.jpeg | xargs rm *.jpeg

Fred
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: removing one file type from a large file collection

Postby psyodin on Mon May 12, 2008 2:00 am

i made a small temp file on my desktop called temp that has subfolders,mp3's and jpg's to try all this out on just in case

myputer@myputer:~$ cd /home/level5ive/Desktop/temp
myputer@myputer:~/Desktop/temp$ find . -name \*.jpeg | xargs rm *.jpeg

rm: cannot remove `*.jpeg': No such file or directory



myputer@myputer:~$ cd /home/level5ive/Desktop/temp
myputer@myputer:~/Desktop/temp$ find . -name \*.jpg | xargs rm *.jpg

rm: cannot remove `*.jpg': No such file or directory
rm: cannot remove `./Faith': No such file or directory
rm: cannot remove `Hill/Fireflies/AlbumArtSmall.jpg': No such file or directory
rm: cannot remove `./Faith': No such file or directory
rm: cannot remove `Hill/Fireflies/AlbumArt_{CF99805B-E9CE-440E-8F6A-E3187FD0541F}_Large.jpg': No such file or directory
rm: cannot remove `./Faith': No such file or directory
rm: cannot remove `Hill/Fireflies/Folder.jpg': No such file or directory
rm: cannot remove `./Faith': No such file or directory
rm: cannot remove `Hill/Fireflies/AlbumArt_{CF99805B-E9CE-440E-8F6A-E3187FD0541F}_Small.jpg': No such file or directory
rm: cannot remove `./Faith': No such file or directory
rm: cannot remove `Hill/AlbumArtSmall.jpg': No such file or directory
rm: cannot remove `./Faith': No such file or directory
rm: cannot remove `Hill/AlbumArt_{9E97E25A-3B52-4C5A-AA63-7BFD552F454D}_Small.jpg': No such file or directory
rm: cannot remove `./Faith': No such file or directory
rm: cannot remove `Hill/AlbumArt_{9E97E25A-3B52-4C5A-AA63-7BFD552F454D}_Large.jpg': No such file or directory
rm: cannot remove `./Faith': No such file or directory
rm: cannot remove `Hill/Folder.jpg': No such file or directory
rm: cannot remove `./Celtic': No such file or directory
rm: cannot remove `Woman/AlbumArt_{5C069418-EE88-46F0-8819-1F3042732D0C}_Large.jpg': No such file or directory
rm: cannot remove `./Celtic': No such file or directory
rm: cannot remove `Woman/AlbumArtSmall.jpg': No such file or directory
rm: cannot remove `./Celtic': No such file or directory
rm: cannot remove `Woman/Folder.jpg': No such file or directory
rm: cannot remove `./Celtic': No such file or directory
rm: cannot remove `Woman/AlbumArt_{5C069418-EE88-46F0-8819-1F3042732D0C}_Small.jpg': No such file or directory
rm: cannot remove `./Dreamworld-': No such file or directory
rm: cannot remove `Essential': No such file or directory
rm: cannot remove `Late': No such file or directory
rm: cannot remove `Night': No such file or directory
rm: cannot remove `Listening/AlbumArtSmall.jpg': No such file or directory
rm: cannot remove `./Dreamworld-': No such file or directory
rm: cannot remove `Essential': No such file or directory
rm: cannot remove `Late': No such file or directory
rm: cannot remove `Night': No such file or directory
rm: cannot remove `Listening/AlbumArt_{753CEB90-141E-42BE-AE6B-B545B970C483}_Large.jpg': No such file or directory
rm: cannot remove `./Dreamworld-': No such file or directory
rm: cannot remove `Essential': No such file or directory
rm: cannot remove `Late': No such file or directory
rm: cannot remove `Night': No such file or directory
rm: cannot remove `Listening/Folder.jpg': No such file or directory
rm: cannot remove `./Dreamworld-': No such file or directory
rm: cannot remove `Essential': No such file or directory
rm: cannot remove `Late': No such file or directory
rm: cannot remove `Night': No such file or directory
rm: cannot remove `Listening/AlbumArt_{753CEB90-141E-42BE-AE6B-B545B970C483}_Small.jpg': No such file or directory
rm: cannot remove `./Eric': No such file or directory
rm: cannot remove `Clapton/Journeyman/AlbumArtSmall.jpg': No such file or directory
rm: cannot remove `./Eric': No such file or directory
rm: cannot remove `Clapton/Journeyman/AlbumArt_{4C0F28EF-00DA-4AAC-B7E4-78D17C546ACC}_Small.jpg': No such file or directory



heh. its all good i can go thru manually delete things.....my only other option is too transfer to an external HD and use a puter with XP on it then search and delete that way. thanks again
User avatar
psyodin
Level 1
Level 1
 
Posts: 8
Joined: Tue Nov 13, 2007 12:16 am

Re: removing one file type from a large file collection

Postby Fred on Mon May 12, 2008 2:09 am

psyodin

find . -name \*.jpeg | xargs -0 rm

see if this does it.. you may need sudo.

sudo find . -name \*.jpeg | xargs -0 rm
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: removing one file type from a large file collection

Postby Fred on Mon May 12, 2008 2:14 am

looks like they are .jpg not jpeg
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: removing one file type from a large file collection

Postby psyodin on Mon May 12, 2008 2:14 am

ok got it to work i used

find . -type f -name "*.jpg" -exec rm -f {} \;

having changed jpeg to jpg

thanks all for the help and its prolly my error(s) that made other options not work

muchas gracias amigos


edit: ill try that other way too and see what happens

thanks again
Last edited by psyodin on Mon May 12, 2008 2:24 am, edited 1 time in total.
User avatar
psyodin
Level 1
Level 1
 
Posts: 8
Joined: Tue Nov 13, 2007 12:16 am

Re: removing one file type from a large file collection

Postby Fred on Mon May 12, 2008 2:22 am

psyodin,

Well I did have a mistake in my first post. it should have been:

find . -name \*.jpg | xargs -0 rm

All is well that ends well though. :-)

Fred
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: removing one file type from a large file collection

Postby psyodin on Mon May 12, 2008 2:27 am

ahh

well indeed it did end well

your very kind

good evening sir :)
User avatar
psyodin
Level 1
Level 1
 
Posts: 8
Joined: Tue Nov 13, 2007 12:16 am

Re: removing one file type from a large file collection(solved)

Postby Lysias on Mon May 12, 2008 8:58 am

For some silly reason I got carried away and used *.jpeg ..

Sorry for the fuss psyodin I'm glad everything worked out finally.

Seeing you around.

Lysias
User avatar
Lysias
Level 1
Level 1
 
Posts: 27
Joined: Sun May 04, 2008 6:32 pm

Linux Mint is funded by ads and donations.
 

Return to Newbie Questions

Who is online

Users browsing this forum: Bing [Bot], denali6194, move-on and 32 guests