batch file help...

G

Guest

so i have part of a batch file that has the following:

cd %temp%
for /f "tokens=*" %%i in ('dir /b /s /a-d') do del /f /q %%i >>
"c:\%~n0\delete_temporary.tmp"

my question is how can i only output the files that get deleted, cause
sometimes files cant be deleted due to these errors:
-The process cannot access the file because it is being used by another
process.
-Access is denied.
 
T

Torgeir Bakken \(MVP\)

Royce said:
so i have part of a batch file that has the following:

cd %temp%
for /f "tokens=*" %%i in ('dir /b /s /a-d') do del /f /q %%i >>
"c:\%~n0\delete_temporary.tmp"

my question is how can i only output the files that get deleted, cause
sometimes files cant be deleted due to these errors:
-The process cannot access the file because it is being used by another
process.
-Access is denied.
Hi,

This should work:

--------------------8<----------------------

cd /d %temp%
for /f "tokens=*" %%i in ('dir /b /s /a-d') do (
del /f /q "%%i"
if not exist "%%i" echo %%i>>"c:\%~n0\delete_temporary.tmp"
)

--------------------8<----------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top