Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Log file from batch file  (Read 3763 times)

0 Members and 1 Guest are viewing this topic.

wesil

  • Guest
Log file from batch file
« on: May 02, 2007, 08:06:55 PM »
I created this batch file (XP Cleanup.bat) to faster automate deleting temporary files.  I currently have the batch file logging the user, start, and end time of when it ran.  I would like to have a more detailed log file. For example how many files from each location were deleted and the time to do it. I am not sure that this is even possible.  I found that using the command (dir "%userprofile%\cookies" /b/s /a-d |find /v /c "::" >> Cleanup.txt) would give me the number of cookies/files in the “Cookies” folder. When I try to create a variable with the command (dir "%userprofile%\cookies" /b/s /a-d |find /v /c "::" ) it errors.  Can anyone help me?

Thank you.


XP Cleanup.bat
@ECHO OFF

cd "c:\T1"
echo %userprofile:~26% >> Cleanup.txt
echo Start:  %Date% %time% >> Cleanup.txt

title Deleting Cookies. . .
cd "%userprofile%\Cookies"
del *.* /F /S /Q /A: R /A: H /A: A
cls

title Deleting Internet History. . .. . .
cd "%userprofile%\Local Settings\History"
del *.* /F /S /Q /A: R /A: H /A: A
rmdir /s /q "%userprofile%\Local Settings\History\History.IE5"
cls

title Deleting Local Temp Files. . .
cd "%userprofile%\Local Settings\Temp"
del *.* /F /S /Q /A: R /A: H /A: A
rmdir /s /q "%userprofile%\Local Settings\Temp"
cls

title Deleting Local Users Temporary Internet Files. . .
cd "%userprofile%\Local Settings\Temporary Internet Files"
del *.* /F /S /Q /A: R /A: H /A: A
rmdir /s /q "%userprofile%\Local Settings\Temporary Internet Files\Content.IE5"
cls

title Deleting Windows Temp Files. . .
cd "C:\WINDOWS\Temp"
del *.* /F /S /Q /A: R /A: H /A: A
rmdir /s /q "C:\WINDOWS\Temp"
cls

title Emptying Recycling Bin...
rem must copy nircmd.exe to System32 folder to work
nircmd.exe emptybin
cls

cd "c:\T1"
echo Finish: %Date% %time% >> Cleanup.txt
echo. >> Cleanup.txt

EXIT


Cleanup.txt
Default
Start:  Wed 05/02/2007 21:50:48.78
Finish: Wed 05/02/2007 21:50:48.88

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Log file from batch file
« Reply #1 on: May 03, 2007, 04:51:01 AM »
Code: [Select]
for /f %%i in ('dir "%userprofile%\cookies" /b/s /a-d ^| find /v /c "::" ') do (
   echo %%i >> Cleanup.txt
)

 8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

wesil

  • Guest
Re: Log file from batch file
« Reply #2 on: May 04, 2007, 10:29:39 AM »
Thats got it.

Thank You!