AppleScript access Network Folder

孤者浪人 提交于 2020-01-04 12:49:20

问题


I'm trying to make a backup of a folder on our network to my Desktop but I'm not sure how to access the folder on the shared network. My code is as follows:

on run {input, parameters}

    set desktopFolder to "Macintosh HD:Users:James:Desktop:App Backups:"
    set todayDate to do shell script "date '+%Y.%m.%d'"
    set newFolderName to "Backup " & todayDate
    set destinationFolder to desktopFolder & newFolderName
    set sourceFolder to "smb://svr01/IT_Department/Design/_team/James/App"

    tell application "Finder"
        make new folder at alias desktopFolder with properties {name:newFolderName}
        copy folder sourceFolder to folder destinationFolder
    end tell

    return input
end run

Should I be using the smb://... address or the Volumes/.... address, and how should I format it? I'm a complete AppleScript novice, by the way!

Thanks James


回答1:


copy only copies AppleScript values, not application-defined objects. Use duplicate command.

set sourceFolder to ("/Users/test/Desktop/untitled folder" as POSIX file)
set targetFolder to ("/Users/test/Desktop/untitled folder 2" as POSIX file)
tell application "Finder" to duplicate sourceFolder to targetFolder 

You can use smb://... address.



来源:https://stackoverflow.com/questions/18251249/applescript-access-network-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!