?
Solved

get delete confirmation

Posted on 2007-12-05
4
Medium Priority
?
482 Views
Last Modified: 2012-08-13
I am piping the output of a batch file to a text file.  one part of my batch file deletes a file and i want that output also to go to the text file.

But when you type in del filename.txt in a command window there is no confirmation that it succeeded.

Is there a flag you can put with the del command so it comes back and says it was successful?
0
Comment
Question by:Fraser_Admin
[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
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
Ashish Patel earned 1500 total points
ID: 20411053
No del command doesnt have anything which says that it was successfull, rather it will give erro if file isnt found or is read only. So, what you do is to trace could not find ..... error after del command is executed and if this message is found then its an error or else everything is good.
0
 

Author Comment

by:Fraser_Admin
ID: 20411090
can you post an example of how I would check if the delete was successful so i can echo my own message if it was.
0
 
LVL 23

Expert Comment

by:Ashish Patel
ID: 20411133
You can find some articals on this on google. I havent tried this, but i know this is the work around.
0
 
LVL 3

Expert Comment

by:yjwong
ID: 20411237
Use the command prompt errorlevels to detect whether an operation is successful. The del command will return 0 (zero) on success, nonzero on failure. Without further ado, here's a sample script (note that I've not tested the script, it may or may not work, but I believe it is a good reference.

Outputs:
File deletion successful!
Failed to delete file!
del myexistentfile.txt
if not %errorlevel% == 0 goto fail:
echo File deletion successful!
 
del mynonexistentfile.txt
if not %errorlevel% == 0 goto fail:
echo File deletion successful!
 
fail:
echo Failed to delete file!

Open in new window

0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

800 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