AppleScript access Network Folder

2019-07-17 22:08发布

问题:

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.