2

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

我基本上想将 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
4

2 回答 2

0

假设您的“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

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

于 2018-03-08T18:48:07.190 回答
0

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

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

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

于 2019-05-13T10:03:59.350 回答