General :: How To Delete All Folders And Their Contents Except 3
Jan 28, 2010
I have a USB drive that has a TON of folders on its root level. I want to remove all those folders and their contents except three of them. I know if I do rm -rf that will kill everything, is there a way to exclude three folders, say folder1 folder2 newfolder, and do it all in one statement?
I want all files and folders and subfolders and images and everything inside of public_html. Also to be saved on the same folder so i can find it easy How can i do it?
I want to do something like svn add dir1 dir2; svn ci dir1 dir2 but have it be only 1 revision. Is there a way to do this? Is this the correct way to add new folders (with contents) to the repository? We are restructuring the trunk, so I cleared it out and plan on putting these directories with their contents in it.
I just had a bad experience with a server, and now i have a 17GB lost+found. It appears a lot of the stuff in there are folders which are empty. Since those really serve no purpose as far as recovering data from what I can tell, is there a slick way to delete just the empty folders from my /data/lost+found folder, leaving me with just the stuff I truly need to look through?
How would i delete all the folders access one i specify.for example if a there are 4 folders namely a b c and d. How would i prevent deleting folder b .Whatever folders other than b should be deleted?
I am happy to report I successfully setup a cloning station using Ubuntu 10.4 Lucid Lynx and Clonezilla. I learned the hard way you have to restore images to a hard drive of a larger size than the drive the image was ripped from. I had already ripped 6 or more images and have them in the Home_Partimag folder and cannot delete or rename these images. I want to remake these images and rip them from smaller hard drives. Any commands I can use to be able to do this?
I want to know how much damage a user can do on my system if he decides to delete everything (or write to in case of corruption).What command or script might i use to check this?
i have been copying dvd's and now i do not have enough room in my temporary folder,but i cannot find out how to delete the folders and make space to continue
Is there a way to recreate all the folders from one directory to another without copying over the contents of the folder? I've been trying to do something like this,
Code:for i in `ls $X`; do mkdir $PATH/$i; doneUnfortunately $i is deliminated by whitespaces in the filenames and not the actual folders.
$X contains only other folders so I dont have to worry about regular files but any kind of more "advanced" solution would work.
I am administrating a lab in a university and every semester we need to delete all the home folders of the accounts for the next semester. I would like to make a bash script that does this automatically and having trouble with it. Note that I am writing my very first bash script. What I need to do is make a script to delete the following:
Delete everything in /home/$exp$num/$dir when "exp" could be either "rt", "ic" or "sp". "num" could run from 1(single digit) to 45 and dir is "profile" and "work".
This is what I tried to write:
Code:
#!/bin/sh cd /home for exp in "rt ic sp" do
[code]....
What seems to be the problem is the reading of "$exp$num" as a joint expression.
I have an archive directory that needs to be cleaned up once per quarter. The top level (/data/archive/*) directory names change daily, as well as the subdirectories and the filenames (the application names everything according to date). Also, there are two top level directories, bin and incoming, that we can't touch. I want to write a shell script that loops through the 15 or 20 top level directories and deletes all files and subdirectories older than 3 days (skipping the bin and incoming folders). Can someone get me started on a script? I am kinda new to shell scripting.
i locked a folder of pictures on my linux and now want to delete them, but it wont even let me open the folder or do anything with it, what do i do to unlock it then delete i
I have a set of folders in some directory /home/dir, and I'd like to generate zip files for the contents of each folder separately. I'm wondering if there's a quick way to do this with a one-liner, or what the bash script would be.
Directory structure: /home/dir/first/second/thirdand I want three files, first.zip, second.zip, and third.zip. I know zip isn't the best format, but these are for distribution to users on Windows machines and I'd prefer to keep them in the zip format.
/root/.local/share/Trash/files/I have a tar backup file in there and can't get rid of it. I've tried from root with Nautilus, the files disappear for a couple of seconds and then reappear.
Instead of using the Firefox Better Privacy addon or the Macromedia website to manage Flash Cookies (LSO's), I would just like to periodically, delete the ~/.macromedia/Flash_Player/#SharedObjects directory.
I've created a new group and a new user called dftp... Now I wanna do one thing... If 'dftp' connects thru ftp he should be directed to a particular location... and he shouldn't be able to see other folder except for his own including the parent folder that contains that location... I changed dftp's home folder to the location I want. However while connecting thru ftp. user dftp has been given permissions to see other folders and check out the contents of the other folders.
I recently had to rescue files from a dying hard drive using Photorec. However, it dumped the files randomly in many different directories. Is there a way I can transfer the contents of these directories into one master directory without the file structure. For example, I have folders 1 through 10 as subdirectories in folder X. How can I transfer the contents of all those folders into folder Y while getting rid of the subdirectories 1 - 10?
Recently, Ubuntu was doing a standard update. It got stuck in some kind of strange loop. So i put the boot disk in cleared the master drive and reinstalled ububtu 10.4. I have a backup 500gb drive that use to keep the contents of my important information for my fileserver. After the completed install and found the backup drive STILL named "FILESERVER" and still has my folders aka: our pictures, our music, and our video. I opened them up and they're all empty. Am I missing some informaton? I swear i didn't format the drive. I couldn't have since the folders are still there. Where are all my files at?
I have a parent folder, with a lot of sub folders. basically, i'd like to bring all the contents from the sub folders into the parent folder, and subsequently delete the sub folders. is there one command for this? or do i need to cp -r over and over again, and then manually delete?
Im assuming there is a simple answer for this but I have yet to find it in forums. I have 2 partitions mounted on my ubuntu desktop, one is Windows C: drive labeled "Core" and the other is D: drive labeled "Reserve" but for some reason I have a second Windows folder on my desktop, when I attempted to delete it it began to delete the Windows files as well, one forum said to right click and "remove from desktop" but this option isnt in the menu. How can I just delete the folder?
I have a directory that has a another directory inside it. The top directory is rather redundant since it only contains the one other one. Is there a way to delete the top level directory and have the contents simply "move up a level"?
Many folders within a subdirectory some of which have lots of data in and some of which have only one specific file called produkt.fil inside.I need a command to find and delete those folders that contain ONLY the file produkt.fil - if other files exist (doesnt matter what they are) then they should be left alone. Note: produkt.fil exists in all of the folders always.