Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output from a delete command

Status
Not open for further replies.

pronstar

MIS
Aug 26, 2002
14
0
0
US
All,

I have a bi-monthly scheduled task that deletes certain files based upon a timestamp. As part of this batch file process, I'd like to have an output of the names of the files deleted. Any idea on how to accomplish this?

The del command does not output any info. The 'fileman.vbs' cscript can not use *... and I need to use them as I am calling many files in a directory... (like ms_200209*.zip.)

Any advice/suggestions are welcome!!! Thanks!!!
 
Have you tried capturing the output of the DEL command to a file?

del *.fil >test.txt

Most console commands do write to stdout and therefore their output can be captured to a text file that you can parse. There are exceptions, "route /?" is one that writes directly to the display and its output isn't normally captured with a pipe or output redirection, interestingly enough, it seems to only do it with its built in help screen. If you've ever tried to do a route|more to get the help to pause you've experienced it.
 
sind the dir command will respond to the same wildcards as the del command

dir like ms_200209*.zip >>FileName

should produce a listing
 
Sorry, I may have misunderstood what you were getting at.

You could parse the output of the directory listing matching your criteria deleting each of the desired files individually within the script, watching for an error condition for a success or failure.
 
MalibuJack,

Thanks for the info! Capturing the output of the DEL command IS what I'm trying to accomplish! Unfortunately, when I use the DEL command, there is no output...Yet Files are deleted.

Dadoalex,

The dir like ms_200209*.zip >>FileName command will show me a list of files like ms_200209*.zip...right? However, I am really trying to capture a list of the files being deleted. I suppose that I can add that command to the script prior to the delete...but that still seems a bit shaky to me.

I really appreciate the thoughts and insight!!!!

 
Trys sing del filename*.txt /s /q > deleted.txt

Worked for me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top