如何安排从下载目录中删除数据 - Windows

时间:2017-09-07 08:09:48

标签: windows

我正在开发应用程序,将数据下载到Downloads目录,在某些时间段后不再需要。有没有办法在一段时间内删除这些下载的文件?

2 个答案:

答案 0 :(得分:2)

** open  into note pad and 
                delete script : ** 

            REM Remove files older than 30 days
            forfiles /p “C:\deletefolder name” /s /m *.* /c "cmd /c Del @path" /d -30 


    1 . Here  C:\deletefolder  path folder and save file name (like downloadcleanup.bat )with .bat extension
    2 . Open tack scheduler
    3.Right Click to Task Scheduler option and then select new tack schedule
    4. Select  .bat  file path you have saved
    5.and also you can see step into below images:
    6. Continue to finish and you can seen your tast in your task scheduler and select to run at a time and also run automatically by schedule time 
      [1]: https://i.stack.imgur.com/Em8f5.png
      [2]: https://i.stack.imgur.com/EXn9b.png
      [3]: https://i.stack.imgur.com/ZqaCe.png
      [4]: https://i.stack.imgur.com/S8Lxy.png
      [5]: https://i.stack.imgur.com/lGqxX.png
      [6]: https://i.stack.imgur.com/QGFRL.png
      [7]: https://i.stack.imgur.com/a0RRq.png
      [8]: https://i.stack.imgur.com/8L0NC.png
      [9]: https://i.stack.imgur.com/7v9SV.png

答案 1 :(得分:0)

您可以使用您喜欢的语言(例如PowerShell或Python)编写脚本,该脚本将定期检查下载目录并根据其时间戳删除不必要的文件。但是,您应该小心并彻底测试您的脚本 - 您必须确保它按预期工作,并且不会删除仍然存在的文件。