Solved

batch script:  remove file names starting with certain characters

Posted on 2010-08-18
6
497 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ROOT\*0700\1_0_13_0_0_0 8 159
Can I use memory from Lenovo T430 in an IBM T61 3 92
HP PC Hardware Diagnostics UEFI 11 187
MS-Access 2002 error (Win XP on Win7Pro) 19 133
cPanel is a Unix based web hosting control panel that provides a graphical interface and automation tools designed to simplify the process of hosting a web site. cPanel utilizes a 3 tier structure that provides functionality for administrators, rese…
It is only natural that we all want our PCs to be in good working order, improved system performance, so that is exactly how programs are advertised to entice. They say things like:            •      PC crashes? Get registry cleaner to repair it!    …
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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