batch script: remove file names starting with certain characters

I have a windows batch script which I use to delete certain file names and file sizes from various directories.
 
I want to add a line in the script that deletes all files starting with certain characters (specificlly "~"  and "z") within the directory.  

I know some people like to ask why questions so here it is...
I have a game-server and my players use this script to clean up game directories that get filled with trash files from other servers.  These files change everything from menus to graphics (bad thing).  It just so happens that these server owners start the files with "~" and "z" to make this happen (which is a different subject).  So my script would be more efficient if I can target just the files that start with these characters.  

Please submit an example script from start to finish, do not assume I can fill in the blanks.  

Thanks in advance.  

icecom4Asked:
Who is Participating?
 
trythisoneConnect With a Mentor Commented:
if you want it to find all of the instances of that name, plus search subdirectories use:


del /s /Q "c:\whatever path\~*.*"

the /Q makes it not prompt you if you want to delete the files.
0
 
Rob SiddellCommunity Educator IICommented:
del ~*.* z*.*
0
 
Rob SiddellCommunity Educator IICommented:
you will need to change the directory first so it would be

cd c:/location/location
del ~*.* z*.*

0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Lee W, MVPTechnology and Business Process AdvisorCommented:
People ask why questions so they have a context and provide you the best answer - and sometimes the best answer is one you didn't even think could be done.
0
 
icecom4Author Commented:
very nice.  This line works.  Thanks!
0
 
icecom4Author Commented:
ooops mis posted sorry
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.