Solved

batch script:  remove file names starting with certain characters

Posted on 2010-08-18
6
493 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
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 95

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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Can you find a fax from a vendor you saved a decade ago in seconds? Have you ever cursed your PC under your breath during an audit because you couldn’t find the requested statement or driver history?  If you answered no to the first question or yes …
If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now