【问题标题】:Applescript to copy file from Google Team DriveApplescript 从 Google Team Drive 复制文件
【发布时间】:2018-08-16 05:32:39
【问题描述】:

我正在尝试将 Google 团队云端硬盘上的文件夹复制到另一个位置,但我的脚本不断出错。完整的脚本如下。

我基本上想将 Excel 文件“Google Drive:Team Drives:Company -Sync Folder:0000-1_E.xlsx”复制到脚本定义的位置。

违规行是:

duplicate file "Google Drive:Team Drives:Company -Sync Folder:0000-1_E.xlsx" of startup disk to folder (jobNum & " Documents") of newJobFolder

有什么帮助吗?

global jobNum
global newJobFolder
set jobNum to text returned of (display dialog "Enter a job number:" default answer "")
set jobName to text returned of (display dialog "Enter a job name:" default answer "")
set jobMgr to text returned of (display dialog "Enter account manager email:" default answer "")
set folderpath to (choose folder with prompt "Select client folder")
set newJobFolder to my newFold(jobNum, jobName, folderpath, jobMgr)


on newFold(theNumber, theName, thefolder, jobMgr)
    set emailAddress to jobMgr
    set emailSubject to theNumber & " -" & theName
    set bodyText to ""
    set emailLinkFileName to theNumber & " -" & theName

    set subNameList to {"Designs", "Documents", "Received"}
    set itemCount to count of subNameList
    set linkBody to "mailto:" & emailAddress & "?subject=" & my replace_chars(emailSubject, " ", "%20") & "&body=" & my replace_chars(bodyText, " ", "%20")
    tell application "Finder"
        set newJobFolder to (make new folder at thefolder with properties ¬
            {name:theNumber & " " & theName})
        repeat with i from 1 to itemCount
            set aSubFolder to make new folder at newJobFolder with properties {name:jobNum & " " & item i of subNameList}
            set theMailto to make new internet location file to linkBody at aSubFolder with properties {name:emailLinkFileName, name extension:"mailloc"}
            set the name extension of theMailto to "mailloc"
        end repeat
        duplicate file "Google Drive:Team Drives:Company -Sync Folder:0000-1_E.xlsx" of startup disk to folder (jobNum & " Documents") of newJobFolder
        set name of the result to jobNum & " E.xlsx"
        set theMailto to make new internet location file to linkBody at newJobFolder with properties {name:emailLinkFileName, name extension:"mailloc"}
        set the name extension of theMailto to "mailloc"
    end tell
end newFold

-- Generic find and replace functionality
on replace_chars(this_text, search_string, replacement_string)
    set AppleScript's text item delimiters to the search_string
    set the item_list to every text item of this_text
    set AppleScript's text item delimiters to the replacement_string
    set this_text to the item_list as string
    set AppleScript's text item delimiters to ""
    return this_text
end replace_chars

【问题讨论】:

  • 给出什么错误信息?
  • Finder 出现错误:无法将启动盘文件夹“用户”文件夹“ace”文件夹“桌面”文件夹“0000 test0000”文件夹“0000 文档”设置为文件“团队” Drives:Company -Sync Folder:0000-1_E.xlsx" 的启动盘。
  • 如果您的 Google Drive 文件夹是挂载的驱动器,那么它不是 Startup Disk 的子文件夹。尝试从问题行中删除of startup disk

标签: applescript google-drive-shared-drive


【解决方案1】:

假设您的“Google Drive”文件夹直接位于您的主文件夹中...

尝试改变这个...

duplicate file "Google Drive:Team Drives:Company -Sync Folder:0000-1_E.xlsx" of startup disk to folder (jobNum & " Documents") of newJobFolder

到这里……

set theFile to (path to home folder as text) & "Google Drive:Team Drives:Company -Sync Folder:0000-1_E.xlsx"
duplicate file theFile to folder (jobNum & " Documents") of newJobFolder

如果这不起作用,您可以尝试这种方法...

set theFile to (choose file) as alias as text
duplicate file theFile to folder (jobNum & " Documents") of newJobFolder

然后在你运行一次之后,注释掉选择文件命令。

【讨论】:

  • google 驱动器是已安装的驱动器,因此它出现在设备中我们正在使用新的 google 文件流,因此不再显示为文件夹
【解决方案2】:

如果您使用的是企业专用的 Google Drive File Stream,则可以通过用户文件夹访问已安装的驱动器,路径如下:

"/Users/nameofuser/Google Drive File Stream/My Drive/Companyfolder"

使用这种格式来访问文件夹,它应该可以工作,这就是我所做的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-14
    • 2018-06-15
    • 1970-01-01
    • 1970-01-01
    • 2020-12-16
    • 2021-12-21
    • 1970-01-01
    相关资源
    最近更新 更多