Solved

get delete confirmation

Posted on 2007-12-05
4
475 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
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
Ashish Patel earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

11 Experts available now in Live!

Get 1:1 Help Now