Reputation: 676
I am able to create a bacth file to delete files older than n days but i am having problem with saving the deletion results. What i want is listing the deletion result in a text file after the process.
I have tried this code below. It works and delete all files. It also creates result.txt but the txt file is empty. I am seeing that files are being deleted. Any idea why they are not being saved in the text file?
forfiles -p "C:\Log\" -s -m *.* /D -1 /C "cmd /c del @path" >> "c:\result.txt"
Upvotes: 1
Views: 1111
Reputation: 41234
This will provide a log of files that have been used with the del command, but not a confirmed result.
If a file is read only for example then it will still exist.
forfiles -p "C:\Log\" -s -m *.* /D -1 /C "cmd /c del @path & echo @path >>c:\result.txt"
Upvotes: 2