user2953386
user2953386

Reputation: 33

Checking if a file has been edited

I want to know if there is a way to check if a file has been edited. I looked for methods that can make it for me on Google Apps library, but I have found nothing about it. I don't know if I searched wrong.

Basically, I need to take a file, take a measurable data (something like size) of this file and store on a variable. Then, I need to take that measurable data again, store on another variable, and compare if there was a change. I need a boolean return.

Anyone?

Upvotes: 2

Views: 1251

Answers (2)

Chris Cirefice
Chris Cirefice

Reputation: 5795

You could do the following (pseudo with links to documentation):

  1. Get the file you want to check using the DocList Class.
  2. Get the ID of that File once you have it using File.getID()
  3. Get the last edit timestamp using File.getLastUpdated()
  4. Store this value in a Spreadsheet, or maybe Script or User Properties.
  5. When you want to check to see if the File was updated, simply File.getFileById()
  6. Repeat step 3.
  7. Then compare the two last-edited timestamps with an operator like !=, or do more complex comparisons on the Dates if you want.
  8. Depending on the result of step 7, return true or false.

Google's documentation is great, for all their services. You just need to read it a bit to understand what kind of power you have through scripting. Hopefully my pseudo-method helps in solving your problem!

Upvotes: 4

Zig Mandel
Zig Mandel

Reputation: 19835

Look at the file update date: https://developers.google.com/apps-script/reference/drive/file#getLastUpdated() and for storing data look up the storing data section in the apps script help page.

Upvotes: 0

Related Questions