The How-To Geek Forums Have Migrated to Discourse


How-To Geek Forums / Geek Stuff

(Solved) - Search and delete using CMD

(11 posts)
  • Started 9 years ago by ian2
  • Latest reply from LH
  • Topic Viewed 6268 times

ian2
Posts: 0

Could someone tell me how to go about searching for and deleting all files using the command prompt.
In my case I need to find all instances of file names containing the word Qigong.
I am using windows 7 if that matters.
I can find them all using search but I would like to automate the process.
I have been doing photo and video editing for people and would like to speed up the
process of ridding my computer of their files..

Posted 9 years ago
Top
 
ispalten
Posts: 0

Well, it could still take time and manual intervention to do this...

The basic DOS command would be "DIR *qigong* /s" which would show you ALL files on THAT drive that have Qigong in them. Then you'd have to do manual deletes.

You could do DIR *qigong* /S >textfile.bat and then EDIT that file to do DEL's, but it would take a lot of editing adding the path to the filename and putting DEL in front of that and then running it.

However, try LOOKING HERE, it appears if you enter *qigong* it will locate all and you can mass delete from within the program?

Irv S.

Posted 9 years ago
Top
 
algotechie
Posts: 0

Hi ian2

Enter the following command to list all the files containing the word Qigong on drives "C:\" through "E:\" (you can similarly add more lines if you need to search more drives):

dir C:\*Qigong*.* /s
dir D:\*Qigong*.* /s
dir E:\*Qigong*.* /s

Make sure these are the files you want to delete. (The next command will delete all these files and you won't be able to recover them from Recycle Bin.) Here are the lines that you'd enter to delete the above files. (Add more if you have such files on other drives.)

del C:\*Qigong*.* /s
del D:\*Qigong*.* /s
del E:\*Qigong*.* /s

If you wanna automate the process even more, open Notepad and type the following (again, add more lines as needed for additional drives):

@echo OFF
echo Following is a list of files containing the word Qigong on your hard drives:
echo ____________________________________________________________________________
dir C:\*Qigong*.* /s
dir D:\*Qigong*.* /s
dir E:\*Qigong*.* /s
echo ____________________________________________________________________________
echo.
echo If you don't want to delete any of the above files, close this window now!
echo The batch will now delete the above files.
pause
del C:\*Qigong*.* /s
del D:\*Qigong*.* /s
del E:\*Qigong*.* /s
echo ____________________________________________________________________________
echo.
echo The batch will now terminate...
pause

Save the file anywhere (say, on your Desktop) with any name and an extension .BAT (like "Qigong.BAT"). Double/click to run it whenever you wish to search and/or delete those files.

Hope that works for you.

Accepted Answer · Posted 9 years ago
Top
 
algotechie
Posts: 0

Sorry, wait! Please do not include the word Qigong in the name of the BAT file you're creating. My bad!

Posted 9 years ago
Top
 
LH
Posts: 0

algo. You want me to delete that post so you can redo it ?

Posted 9 years ago
Top
 
ian2
Posts: 0

Its OK I get the point do not include name "Qigong " in the naming of bat file.

Posted 9 years ago
Top
 
ian2
Posts: 0

Thanks for that Algotechie appreciated muchly!!

Posted 9 years ago
Top
 
algotechie
Posts: 0

You're welcome. This was the first time my answer was marked Accepted. Felt a bit happy.

LH. Sorry for being late. But I'll be more careful next time. But as you know, a bug can be detected any time in a program, no matter how simple it is. So it cannot be guaranteed that all the mistakes would always be caught immediately. At times we have to put up with such things...

Posted 9 years ago
Top
 
LH
Posts: 0

algotechie. No need for sorry, you are doing well in helping others :)

Posted 9 years ago
Top
 
ditoh1
Posts: 0

I know this post is classified as SOLVED, but could someone tell me how to perform a search string within a file, or in this case, a group of files with the same extension?

Posted 7 years ago
Top
 
LH
Posts: 0

ditoh1 hi. Please can you start your own New Topic for your problem.

Posted 7 years ago
Top
 



Topic Closed

This topic has been closed to new replies.

The Best Tech Newsletter Anywhere

Join 250,000 subscribers and get a daily digest of news, geek trivia, and our feature articles.