Applescript для копирования файла с Google Team Drive

Я пытаюсь скопировать папку на общем диске Google в другое место, но мой скрипт продолжает получать ошибку. Полный скрипт ниже.

В основном я хочу скопировать файл Excel «Google Диск: Совместные диски: Компания - Папка синхронизации: 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

person Paddington    schedule 08.03.2018    source источник
comment
И какое сообщение об ошибке выдается?   -  person CJK    schedule 08.03.2018
comment
Finder получил ошибку: Не удается установить папку 0000 Документы папки 0000 test0000 папки Рабочий стол папки ace папки Пользователи загрузочного диска в файл Team Drives: Company -Sync Folder: 0000-1_E.xlsx загрузочного диска.   -  person Paddington    schedule 08.03.2018
comment
Если, как вы сказали ниже, ваша папка Google Диск является подключенным диском, то она не является подпапкой Загрузочного диска. Попробуйте удалить of startup disk из проблемной строки.   -  person CJK    schedule 11.03.2018


Ответы (2)


Предполагая, что ваша папка «Google Диск» находится непосредственно в вашей домашней папке...

Попробуйте изменить это...

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

Затем, после того, как вы запустите его один раз, закомментируйте команду выбора файла.

person wch1zpink    schedule 08.03.2018
comment
Диск Google — это смонтированный диск, поэтому он появляется на устройствах. Мы используем новый файловый поток Google, поэтому он больше не отображается как папка. - person Paddington; 09.03.2018

Если вы используете Google Drive File Stream, предназначенный для предприятий, доступ к подключенному диску можно получить через пользовательскую папку, путь примерно такой:

"/Users/имя пользователя/Файловый поток Google Диска/Мой диск/Корпоративная папка"

Используйте этот формат, чтобы добраться до папок, и он должен работать, я так и делаю.

person victoriam022    schedule 13.05.2019