Windows 7 cmd to empty recycle bin/downloads with log file results

  • Thread starter Thread starter Kala Sha Jahan
  • Start date Start date
K

Kala Sha Jahan

I am using the following to empty the recycle bin for all users:

NOTE: The below is larger batch file that is used to backup files to the server, etc. After the backup is completed, the following is completes the batch file...


ECHO %time% Empty Recycle Bin From All User Accounts >> C:\BackUpHistory\Report.txt

rd /s %systemdrive%\$Recycle.bin /q

ECHO %time% Finished Empty Recycle Bin From All User Accounts >> C:\BackUpHistory\Report.txt


ECHO %time% Removing Files/Folders from UserProfiles Downloads older than 30 days >> C:\BackUpHistory\Report.txt

ForFiles -p "%userprofile%\Downloads" /s /d -30 /c "cmd /c IF @isdir == TRUE rd /S /Q @path"

ECHO %time% Finished deleting Downloads older than 30 days >> C:\BackUpHistory\Report.txt



Both of these works from the batch file, but i cannot get the results into a log file (Report.txt) so I have a record of what was deleted. Is there an easy way to accomplish or generate a list of the files/folders that were deleted and report that back into the Report.txt file?


I tried the ECHO preceding the two relevant lines, but that did not work.


Thank you,


Jat

Continue reading...
 

Similar threads

Back
Top