@@ -0,0 +1,2316 @@
+#imports%0Aimport dropbox%0Aimport datetime%0A%0Adef getPresent():%0A    #obtain and convert the server time to year, month, date%0A        current_time = datetime.datetime.now()%0A        current_year = current_time .year%0A        current_month = current_time .month%0A        current_day = current_time .day%0A        present = datetime.datetime(current_year, current_month, current_day)%0A        return present%0A%0Adef getTimeDifferenceInSeconds(present, past):%0A    d = present - past%0A    return d.total_seconds()%0A%0Adef getDeletionApproval(timeDifferenceInSeconds):%0A    # 1, 209, 600 seconds in 10 days%0A    if timeDifferenceInSeconds %3E 864000:%0A        return True%0A%0Adef deleteTheFile(pathToFile):%0A        client.file_delete(pathToFile)%0A%0A#get the current date%0Apresent = getPresent()%0A%0A#access the drop box account%0Aclient = dropbox.client.DropboxClient(%22_GSRrTwYHmEAAAAAAAAAB1zpOghn4aJz2E04vC-lmC-oENW1pv0O3DUccAkoV43h%22)%0A%0A#get a dict of all files in the specific dropbox api folder%0Afolder_metadata = client.metadata('/')%0A%0A#load the contents dict (actual list of files within the app folder) into a list variable%0Amd = folder_metadata%5B%22contents%22%5D%0A#check that we don't delete files in the even that the files have stopped being placed in Dropbox by the back up script (want at least 5 files on hand)%0A#TODO perhaps find the difference in seconds for all files and delete from oldest to newest until either all old ones are gone or there are only 5 of the newest remaining%0Aif len(md) %3E 5:%0A        #loop through the contents%0A        for item in md:%0A                #reset deletion approval to false%0A                deletionApproval = False%0A                #obtain and convert dropbox date to year, month, date%0A                t1 = datetime.datetime.strptime(item%5B%22modified%22%5D,'%25a, %25d %25b %25Y %25H:%25M:%25S +0000')%0A                year = t1.year%0A                month = t1.month%0A                day = t1.day%0A                past = datetime.datetime(year, month, day)%0A                #get the time difference in seconds%0A                timeDifferenceInSeconds = getTimeDifferenceInSeconds(present, past)%0A                #get approval to delete (default file must be 14 days or older)%0A                deletionApproval = getDeletionApproval(timeDifferenceInSeconds)%0A                if deletionApproval == True:%0A                    deleteTheFile(item%5B%22path%22%5D)%0A

Create remove_files.py