Apps Script - Automatically Delete Files from Google Drive Older than 3 Days - Get List of Files

后端 未结 3 1735
迷失自我
迷失自我 2021-01-01 06:55

I\'m using my Google Drive to store motion detection recordings from my IP cameras at home. I\'m running the following script (slightly modified) to automatically delete fi

3条回答
  •  清酒与你
    2021-01-01 07:17

    I came up with another solution. This only works if your Google Drive files are synced to your hard drive.

    If your Google Drive files are synced to your hard drive, then if you delete them in the local hard drive folder, they also will be deleted from Google Drive as well. So, the mission then becomes how to automatically delete files that are greater than X days old from your Google folder(s).

    This is a Windows Powershell script which will allow you to do just that: https://gallery.technet.microsoft.com/scriptcenter/Delete-files-older-than-x-13b29c09

    Running the script with this configuration:

    powershell -file c:\users\owner\documents\windows\deleteold\deleteold.ps1 -FolderPath "C:\Users\owner\Google Drive\iSpy\video\Bedroom" -FileAge 30 -logfile c:\users\owner\documents\windows\deleteold\logs\Bedroom.log -CreateTime -NoFolder
    

    I am able to delete all iSpy files older than 30 days from my synced Google Drive "Bedroom" folder.

    Following these instructions:

    http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script.aspx

    I am able to run the script automatically using Windows Task Scheduler.

    Problem solved.

提交回复
热议问题