Solved

DOS Command syntax validation

Posted on 2011-09-12
7
308 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
[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
7 Comments
 
LVL 11

Expert Comment

by:jimbecher
ID: 36525989
if not exist file2 goto done:
del file0
del file1
:done
 
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 36526116
Will the application open file3, file4, file5 and so on?
0
 
LVL 11

Accepted Solution

by:
jimbecher earned 125 total points
ID: 36526232
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
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!

 
LVL 11

Assisted Solution

by:Ove
Ove earned 125 total points
ID: 36526416
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 55

Assisted Solution

by:Bill Prew
Bill Prew earned 125 total points
ID: 36526481
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
ID: 36529256

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
ID: 36529302
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

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!

Question has a verified solution.

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

This article will help you understand what HashTables are and how to use them in PowerShell.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

696 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