Skip to content

Instantly share code, notes, and snippets.

Last active Jun 29, 2021
What would you like to do?
from tekdrive import TekDrive
from datetime import date
import os
# Put your access key (with `directory:read` claim) and file id here
here = os.path.dirname(__file__)
def main():
# set up access key authorizer
td = TekDrive(
# find folder with scope measurements to be analyzed
results ="to_be_analyzed")
results_list = list(results)
folder_to_analyze_id = results_list[0].id
# initialize folder instance with found id
folder_to_analyze = td.folder(folder_to_analyze_id)
# grab current date to label and create new folder
folder_name = "analyzed-"+today.strftime("%b%d%Y")
folder_final = td.folder.create(folder_name)
# iterate over each file in the folder
for child in folder_to_analyze.children():
file = td.file(
# create a new local file and download file contents from TekDrive
with open(,"w"):
contents_path = os.path.join(here,
# move the file in TekDrive to a different folder to show that it's been downloaded
# analyze files locally or in TekScope
# upload analyzed files to TekDrive/TekScope
folder_path = os.path.join(here, "analyzed_files")
parent_folder_id = folder_to_analyze.parent_folder_id
parent_folder = td.folder(parent_folder_id)
for file in os.listdir(folder_path):
file_path = os.path.join(folder_path,file)
parent_folder.upload(file_path, file)
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment