Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a directory that has tons of files, and they are named with GUID names.

There are only 3 files in there that I want to keep, and I don't want to move them or anything as the OS might be using them.

How can I delete ALL files in a folder, except for 2 folders and 1 file?

share|improve this question
1  
Select all, hold Ctrl, unselect those that you want to keep, and delete the rest? Or do you want a command line solution? –  slhck Oct 30 '11 at 15:11
    
Ubuntu (or Linux in general) can deal with files that are being moved while they are in use (unless you move them to a different partition). So: mkdir ../tmp ; mv dir1 dir2 file1 ../tmp ; rm * ; mv ../tmp/* . ; rmdir ../tmp. If there are subdirs, make that rm -r *. –  ott-- Oct 30 '11 at 16:22
    
this is on a vps server. –  user27449 Oct 30 '11 at 16:49

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.