PDA

View Full Version : [ubuntu] Remove all folders called Originals in Photo Collection



Daniel591992
April 19th, 2009, 04:58 AM
Hey,

I'd like to get rid of every folder called Originals in my photo collection. How would I do this using the command line?

Thanks

roquefilipe
April 19th, 2009, 03:20 PM
Explore the find command, try something like this:


find /home/ -name *originals* -type d

-type d means it is a directory

I recommend that you use a two step process. First identify what files and folders you want to remove. Then just remove them. It is possible to use the find command to delete the files, but a mistake may be fatal for your data.

Daniel591992
April 19th, 2009, 03:57 PM
Explore the find command, try something like this:


find /home/ -name *originals* -type d

-type d means it is a directory

I recommend that you use a two step process. First identify what files and folders you want to remove. Then just remove them. It is possible to use the find command to delete the files, but a mistake may be fatal for your data.

Hi, I did that and it listed the ones I want to delete. How would I actually delete them though. Thanks

huxain1981
April 19th, 2009, 04:07 PM
try this link
http://www.cyberciti.biz/faq/linux-unix-how-to-find-and-remove-files/

i haven't tried it, so let me know if it works :D

Daniel591992
April 19th, 2009, 08:11 PM
try this link
http://www.cyberciti.biz/faq/linux-unix-how-to-find-and-remove-files/

i haven't tried it, so let me know if it works :D

Hi, I still couldn't find one for folders. Anyone else know?

huxain1981
April 21st, 2009, 06:47 AM
Hi, I still couldn't find one for folders. Anyone else know?



find . -name "FILE-TO-FIND" -exec rm -rf {} \;

this command worked for me.

bladeswords
April 21st, 2009, 06:56 AM
You could just combine the example provided above with the one from the website and it should come out to be...


find /home/ -name *originals* -type d -exec rm -rf {} \;

andrew.46
April 24th, 2009, 12:15 AM
Hi bladeswords,


You could just combine the example provided above with the one from the website and it should come out to be...


find /home/ -name *originals* -type d -exec rm -rf {} \;

A slightly more cautious approach would be:


find $HOME -name 'Originals' -type d -ok rm -rf {} \;

Bearing in mind that there is almost no way to recover files and directories deleted by such a command. In particular the '-r' options means 'recursive' and thus will delete all files and all subdirectories and all of their contents below the level of the directory that has been found. So be very sure this is what you want to do!!

Andrew