Page 1 of 1

[CMD] gDrive - interacting with Google Drive

Posted: 13 Mar 2017, 01:55
by BoBo
gdrive is a command line utility for interacting with Google Drive.

[More...]

8-)

Re: [CMD] gDrive - interacting with Google Drive

Posted: 14 Mar 2017, 02:08
by coolykoen
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:

Re: [CMD] gDrive - interacting with Google Drive

Posted: 14 Mar 2017, 02:25
by BoBo
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-)

Re: [CMD] gDrive - interacting with Google Drive

Posted: 14 Mar 2017, 15:53
by TheDewd
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")
	}
}

Re: [CMD] gDrive - interacting with Google Drive

Posted: 14 Mar 2017, 16:57
by BoBo
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:

Re: [CMD] gDrive - interacting with Google Drive

Posted: 17 Aug 2017, 14:23
by fenchai
Is there a way to detect if Google Drive is syncing at the moment? and also when it is finished?

Re: [CMD] gDrive - interacting with Google Drive

Posted: 18 Aug 2017, 07:23
by BoBo
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 :)