Batch to delete specific files in specific location
Moderator: DosItHelp
Batch to delete specific files in specific location
I wanted to make a batch file that deletes a certain type of file (probably a .txt file) that pops up on the desktop every so often. I believe its java runtime error logs and the better solution would be to update our java program but that is not an option at this time. I would also like to put this batch file in the start up folder of a computer so it executes everytime I turn on the computer. If it can possibly work on winxp and win7 that would be awesome. Just want to get rid of these annoying files for the time being. Thanks.
Re: Batch to delete specific files in specific location
This will delete a file called file.log from the desktop. Put it in the startup group.
Code: Select all
@echo off
del "%userprofile%\desktop\file.log"
Re: Batch to delete specific files in specific location
Thank you. That's pretty good but what if the files have different names? Would I be able to use some wildcards to get it close but not exact on the file name? I think they all look like a .txt file and they all start with the letter "h" in the beginning of the file name. I have to go check. Let me know if this is possible. Thanks for your help.
Re: Batch to delete specific files in specific location
yes. You can use * and ? to match file names.
H*.txt would delete all text files that start with an H.
H*.txt would delete all text files that start with an H.
Re: Batch to delete specific files in specific location
thanks so much. i will try it out. so * and ? does the same thing?
Re: Batch to delete specific files in specific location
data808 wrote:thanks so much. i will try it out. so * and ? does the same thing?
A quick Google search would probably give you the answer but I did that for you.
http://www.microsoft.com/resources/docu ... x?mfr=true
Re: Batch to delete specific files in specific location
Just wanted to come back and let you know that I tried your batch file and it worked like a charm. Thanks so much for your help.