Go Back   TechArena Community > Software > Windows Software
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Bash command to delete entire Files from folder

Windows Software


Reply
 
Thread Tools Search this Thread
  #1  
Old 11-11-2010
Member
 
Join Date: Apr 2010
Posts: 53
Bash command to delete entire Files from folder
  

Hi friends, I want to completely remove the entire files from the specific folder without deleting the folder. I want to remove it via the bash command. What can be the good bash command to delete the files from the folders? I tried what I knew but it encountered me the error message even though I am executing the command in the specific folder. Any trick to delete all the files from the folder without deleting the folder. Please help what can I do?

Reply With Quote
  #2  
Old 11-11-2010
Member
 
Join Date: Sep 2005
Posts: 1,306
Re: Bash command to delete entire Files from folder

Hello friend, I am not the continuous user of UNIX operating system. But I had something idea related to it. You can remove the entire files without deleting the specific folder by the following Bash command: find . -type f -name "*{}*" -exec rm -fr {} \;
You can also test it with the help of IS command, it can be less risky to you: find . -type f -name "*{}*" -exec ls {} \;
The command which I had specified is not yet tested. Because I don’t have the UNIX systems to test this bash commands. Test it let me know what happens?
Reply With Quote
  #3  
Old 11-11-2010
Member
 
Join Date: Apr 2008
Posts: 4,086
Re: Bash command to delete entire Files from folder

Suppose I have being using the 30 other folders, where I have to normally type the folders pathname each and every time. Can I modify the command to remove the entire files which is present in the specific folders? The folder is in the following folder:
A-ABC-20101512-0001
A-ABC-20100322-0002
A-ABC-20100482-0003
………….
Note that the numbers are in the format DDMMYY-NN. I can write the command in the following format: find A-ABC-DDMMYY-NN/folder/subfolder -type f –delete. The given command can be adjusted to the files which you want to remove for each other 30 folders in single command. Without operating it for the other different folder.
__________________
Ram requirement for various OS
Reply With Quote
  #4  
Old 11-11-2010
Member
 
Join Date: Apr 2008
Posts: 2,139
Re: Bash command to delete entire Files from folder

There is no need to search for the command and then execute the command. The command I can give to the system whose content will get deleted from the folders is $ rm -fR "{}*". This command will remove all the files and also directories from the specific folders. –f command represents the system to do the force remove and –R command is recursive. If you want to remove the files interactively then you can ask for the confirmation for each and every file, make use of the –i option in place of the –f option. Try it this will help you.
Reply With Quote
  #5  
Old 11-11-2010
Member
 
Join Date: Dec 2009
Posts: 23
Re: Bash command to delete entire Files from folder

I think kattman is correct. In Linux/UNIX shell, the command to empty out a directory is

Code:
cd "/path/to/directory"
rm -rf *

If you are looking for bash-like commands on windows, biterscripting is your best bet. The commands in biterscripting are


Code:
cd "/path/to/directory"
system -s "del /F /Q *"
Hope this helps.
Reply With Quote
Reply

  TechArena Community > Software > Windows Software
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Bash command to delete entire Files from folder"
Thread Thread Starter Forum Replies Last Post
How to delete files that appear in find command's output in Linux jAYASENA Operating Systems 6 27-05-2011 10:20 AM
Linux bash script with the command w Trini Alvarado Operating Systems 4 22-03-2010 12:11 PM
Print all files in a folder in a single command In Windows Xp Mac rumor Tips & Tweaks 1 13-10-2009 05:53 PM
bash : ipconfig command not found UbuntU-ME Operating Systems 3 11-08-2009 07:16 PM
How to delete folder from the command prompt? Jack Vista Help 7 07-03-2008 10:13 AM


All times are GMT +5.5. The time now is 07:17 PM.