how can I create python script to delete data in temp folder in windows environment system.
Asked
Active
Viewed 1,070 times
-2
-
What have you tried so far? – Vasilis G. Apr 12 '18 at 11:49
-
3Possible duplicate of [How to delete a file or folder?](https://stackoverflow.com/questions/6996603/how-to-delete-a-file-or-folder) – sam Apr 12 '18 at 11:50
1 Answers
1
you can go like this
import os
os.remove("C:\Windows\Prefetch\*.*")
os.remove("C:\Windows\Temp\*.*")
os.remove("C:\Users\Your_User_Name\AppData\Roaming\Microsoft\Windows\Recent Items*.*")

Bhushan Uniyal
- 5,575
- 2
- 22
- 45
-
how can i automate this it should run daily at specified time – KIRAN KUMAR MATAM Apr 12 '18 at 12:00
-
https://blogs.technet.microsoft.com/heyscriptingguy/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script/ – Bhushan Uniyal Apr 12 '18 at 12:01
-
but the code u specified giving error at os.remove("C:\Windows\Prefetch\*.*") itself – KIRAN KUMAR MATAM Apr 12 '18 at 12:04
-
hey I'm Linux user, you should add the correct path for target folders. Linux file system is so far different from window, so i can't help in what is actual path of them, hope it's not a big deal to you. – Bhushan Uniyal Apr 12 '18 at 12:07