Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 503
  • Last Modified:

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.  

0
icecom4
Asked:
icecom4
1 Solution
 
Rob SiddellCommented:
del ~*.* z*.*
0
 
Rob SiddellCommented:
you will need to change the directory first so it would be

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

0
 
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
trythisoneCommented:
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
 
icecom4Author Commented:
very nice.  This line works.  Thanks!
0
 
icecom4Author Commented:
ooops mis posted sorry
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now