Solved

DOS Command syntax validation

Posted on 2011-09-12
7
300 Views
Last Modified: 2012-05-12
Hello,

I have an application that I load via a command line syntax. This application will write debug output to a file and when this file hits 300k, will open the next file incrementing the filename by 1. What I am looking to do via DOS is to delete the original file, file1 and file2 as soon as file2 is opened. That’s it. I don’t want more than 2 files at a time as these file can get large and I don’t want to chew up resources. I am simply trying to figure out how to use DOS to delete these 3 files ONCE File2 is opened.

Thank You
0
Comment
Question by:Charlie_Melega
7 Comments
 
LVL 11

Expert Comment

by:jimbecher
Comment Utility
if not exist file2 goto done:
del file0
del file1
:done
 
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
Comment Utility
Will the application open file3, file4, file5 and so on?
0
 
LVL 11

Accepted Solution

by:
jimbecher earned 125 total points
Comment Utility
You have me really, really confused. I thought the application you were running opened those files

You start and application athe the command prompt. It will create debug info starting at file. When file hits 300k it will close file and open file1. When file1 reached 300k it will close file1 and open file2 at which point you want to delete file, file1 and file2 even though you just opened file2?

I guess what I would like to know is what application you are running and can you interject DOS code int to it?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 11

Assisted Solution

by:Ove
Ove earned 125 total points
Comment Utility
with the following batchfile you'll get what you want:
You'll need some files of the GNU utilities for Win32
from http://unxutils.sourceforge.net/
Install /copy them (GNU utilities) to c:\windows\system32.
Pls set your program.-dir in line 2 and the name of your file(s) in line 3 and 4

****************** snip ************************
c:
cd "\program files\myapp"
dir file* /O:D /B > %temp%\myfiles.txt
grep -c file %temp%\myfiles.txt > %temp%\numberoffiles.txt
Set /p numberoffiles= < %temp%\numberoffiles.txt
del %temp%\numberoffiles.txt
IF "%numberoffiles%" GTR "2" (
    head -n-2 %temp%\myfiles.txt > %temp%\willbedeleted.txt
    for /f %%d in (%temp%\willbedeleted.txt) do del "%%d"
)
************** snap *******************

Ove
0
 
LVL 51

Assisted Solution

by:Bill Prew
Bill Prew earned 125 total points
Comment Utility
You say "as soon as" the new file is created you want the prior one deleted. There's no easy way to do that. But you could create a BAT script something like below and either have it looping with a small delay between iterations, or you could use Task Scheduler and have it run every 10 or 15 minutes maybe?

@echo off
set BaseDir=c:\temp
set BaseFile=filename
set Prior=-1
set Current=0
:Loop
set /A Prior+=1
set /A Current+=1
if exist "%BaseDir%\%FileBase%%Current%" (
  if exist "%BaseDir%\%FileBase%%Prior%" (
    del /Q "%BaseDir%\%FileBase%%Prior%"
  )
  goto :Loop
)

Open in new window

~bp
0
 

Author Comment

by:Charlie_Melega
Comment Utility

just to clarify,  I am running ProcMon using the following syntax:

procmon /Quiet /LoadConfig TEST_config  /Minimized /BackingFile FILE.PML

this will load ProcMon with the specific config file and stat writing output to FILE.PML. After the file reached approximately 300k in size, it will close and open FILE1.PML and so on. Once FILE2 opens, I  want to delete all instances of FILE.* . I just tested this manually and cannot delete FILE and FILE1 even though both of these files are closed, ProcMon has a lock on them and tey cannot be deleted. Obviously, this is more of a problem with ProcMon I have to deal with than DOS syntax so I will need to re-think this. If anyone has thoughts, I'd welcome them.
0
 
LVL 13

Assisted Solution

by:5g6tdcv4
5g6tdcv4 earned 125 total points
Comment Utility
what if you run it in a sandbox, let it do its thing and then dump the sandbox after completion?
http://www.sandboxie.com/
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
A procedure for exporting installed hotfix details of remote computers using powershell
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

771 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

14 Experts available now in Live!

Get 1:1 Help Now