When executing the del delete command, if it succeeds there is no echo output at all; if it fails there will be prompts like file does not exist, etc.
Now I want a prompt after success so it can be distinguished from other cases.
I tried the parameters of del and none of them can do it. Only the /s parameter gives a prompt when deleting a single file, but /s will recursively delete files with the same name in subdirectories, so it isn't safe.
Are there any other delete commands that have this function?
I wrote an echo %errorlevel% command that can show whether the deletion succeeded (actually using dir filename to see whether it still exists), but if I write it on separate lines in a bat it works, while if I write it on one line it may not work because of the & syntax. Please help me see what the problem is:
Successful two-line script:
Unsuccessful one-line script:
Now I want a prompt after success so it can be distinguished from other cases.
I tried the parameters of del and none of them can do it. Only the /s parameter gives a prompt when deleting a single file, but /s will recursively delete files with the same name in subdirectories, so it isn't safe.
Are there any other delete commands that have this function?
I wrote an echo %errorlevel% command that can show whether the deletion succeeded (actually using dir filename to see whether it still exists), but if I write it on separate lines in a bat it works, while if I write it on one line it may not work because of the & syntax. Please help me see what the problem is:
Successful two-line script:
del t.txt
@echo off&dir t.txt>nul 2>&1
echo %errorlevel% &@echo onUnsuccessful one-line script:
del t.txt
@echo off&dir t.txt>nul 2>&1 &echo %errorlevel% &@echo on