Take the 2-minute tour ×

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
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



Browse other questions tagged or ask your own question.