[CMD] gDrive - interacting with Google Drive

Discuss other useful utilities, general computing tips & tricks, Internet resources, etc.
BoBo
Posts: 2515
Joined: 13 May 2014, 17:15

[CMD] gDrive - interacting with Google Drive

13 Mar 2017, 01:55

gdrive is a command line utility for interacting with Google Drive.

[More...]

8-)
coolykoen
Posts: 61
Joined: 01 Jun 2015, 06:10

Re: [CMD] gDrive - interacting with Google Drive

14 Mar 2017, 02:08

BoBo wrote:gdrive is a command line utility for interacting with Google Drive.

[More...]

8-)
Correct me if i'm wrong, but isn't this just advertising? :think:
BoBo
Posts: 2515
Joined: 13 May 2014, 17:15

Re: [CMD] gDrive - interacting with Google Drive

14 Mar 2017, 02:25

Have posted recommendations exactly that way for years at this forum (its predecessor, search for it).
Even using the same format - without a problem.

So I guess, no.

Greetz,
BoBo 8-)
User avatar
TheDewd
Posts: 1135
Joined: 19 Dec 2013, 11:16
Location: USA

Re: [CMD] gDrive - interacting with Google Drive

14 Mar 2017, 15:53

Very nice!

This could be used to create a file browser in AutoHotkey... For example, the code below to get the root directory contents:

Code: Select all

#SingleInstance, Force

GuiCreate() {
    Global ; Assume-global mode
    Static Init := GuiCreate() ; Call function

    Gui, +LastFound -Resize +HWNDhGdrive
    Gui, Margin, 10, 10
    Gui, Add, ListView, xs y+10 w800 r10, Id|Name|Type|Size|Created
    Gui, Show, AutoSize, Example

    Populate("'root' in parents and trashed = false")
}

GdQuery(Query) {    
    File := A_Temp "\GdriveQueryTemp.txt"

    If (FileExist(File)) {
        FileDelete, % File
    }

    RunWait, %ComSpec% /c gdrive-windows-386 list --max 0 --name-width 0 --absolute --query "%Query%" > %File%,, Hide
    FileRead, QueryContents, % File
    return QueryContents
}

Populate(Query) {
    File := A_Temp "\GdriveQueryTemp.txt"
    
    FileContents := GdQuery(Query)

    IdPos := InStr(FileContents, "Id", 1, 1, 1)
    NamePos := InStr(FileContents, "Name", 1, 1, 1)
    TypePos := InStr(FileContents, "Type", 1, 1, 1)
    SizePos := InStr(FileContents, "Size", 1, 1, 1)
    CreatedPos := InStr(FileContents, "Created", 1, 1, 1)

    LV_Delete()

    Loop, Read, %File%
    {
        IfEqual, A_Index, 1, Continue

        Id := RegExReplace(SubStr(A_LoopReadLine, IdPos, NamePos - IdPos), "^\s+|\s+$")
        Name := RegExReplace(SubStr(A_LoopReadLine, NamePos, TypePos - NamePos), "^\s+|\s+$")
        Type := RegExReplace(SubStr(A_LoopReadLine, TypePos, SizePos - TypePos), "^\s+|\s+$")
        Size := RegExReplace(SubStr(A_LoopReadLine, SizePos, CreatedPos - SizePos), "^\s+|\s+$")
        Created := RegExReplace(SubStr(A_LoopReadLine, CreatedPos), "^\s+|\s+$")

        LV_Add("", Id, Name, Type, Size, Created)
    }

    Loop, % LV_GetCount("Col") {
		LV_ModifyCol(A_Index, "AutoHdr")
	}
}
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
BoBo
Posts: 2515
Joined: 13 May 2014, 17:15

Re: [CMD] gDrive - interacting with Google Drive

14 Mar 2017, 16:57

TheDewd wrote:Very nice!

This could be used to create a file browser in AutoHotkey... For example, the code below to get the root directory
I really appreciate it if someone like you offers a sample code to show how AHK could be used that way.
Thanks a lot !! :thumbup:
fenchai
Posts: 190
Joined: 28 Mar 2016, 07:57

Re: [CMD] gDrive - interacting with Google Drive

17 Aug 2017, 14:23

Is there a way to detect if Google Drive is syncing at the moment? and also when it is finished?
BoBo
Posts: 2515
Joined: 13 May 2014, 17:15

Re: [CMD] gDrive - interacting with Google Drive

18 Aug 2017, 07:23

fenchai wrote:Is there a way to detect if Google Drive is syncing at the moment? and also when it is finished?
I'd guess, yes. Check out the tools command lines switches/parameters (stdout/logging) for further details.
Good luck :)

Return to “Other Utilities & Resources”

Who is online

Users browsing this forum: No registered users and 6 guests