Solved

batch script:  remove file names starting with certain characters

Posted on 2010-08-18
6
499 Views
Last Modified: 2012-05-10
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
Comment
Question by:icecom4
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 7

Expert Comment

by:Rob Siddell
ID: 33466798
del ~*.* z*.*
0
 
LVL 7

Expert Comment

by:Rob Siddell
ID: 33466872
you will need to change the directory first so it would be

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

0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 33467052
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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 4

Accepted Solution

by:
trythisone earned 500 total points
ID: 33467153
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
 

Author Comment

by:icecom4
ID: 33468533
very nice.  This line works.  Thanks!
0
 

Author Comment

by:icecom4
ID: 37661861
ooops mis posted sorry
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are 2 things you must have in order to connect to the internet behind a router, The "Gateway IP" of the router, which is usually something like 192.168.xxx.1, I've seen routers with default values of: 192.168.0.1, 192.168.1.1, 192.168.11.1, …
Issue: Unstable cursor in Windows XP and Windows runs extremely slow in that any click will bring up the Hour glass (sometimes for several seconds before giving you what you want) . Troubleshooting Process and the FINAL FIX: This issue see…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question