batch file help...

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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<----------------------
 
Back
Top