我想拥有一个Apple脚本来将用户备份到smb驱动器。
到目前为止,我已经设法在正确的位置创建带有变量的文件夹。这包括日期和当前用户的简短用户名。
我现在正在努力使用rsync将用户文件夹复制到smb上新创建的变量文件夹中。
-- Ask for computer type
set ComputerList to {"macbookair", "macbookpro", "imac", "macmini"}
set ComputerType to choose from list ComputerList with title "Users
Machine" with prompt "What Type of Machine Does the User Have?"
default items "macbookair"
-- Looks for Username
set userName to short user name of (system info)
-- Sets path where folder created
set p to alias "link:to:smb:volume:"
-- Sets current date
set d to short date string of (current date)
set FullDate to d
-- Creates the folder
tell application "Finder" to make new folder at p with properties
{name:FullDate & "_" & userName & "-" & ComputerType}
-- Copies the data
do shell script "rsync -zaP ~/
/Volumes/Goes/Here/VARIABLEFOLDERHERE --exclude='Library' --
exclude='Public' --exclude='Applications"
答案 0 :(得分:0)
您可以使用创建文件夹的行的结果。
Shell脚本需要POSIX路径,强烈建议始终使用quoted form of
来转义路径
tell application "Finder"
set newFolder to make new folder at p with properties {name:FullDate & "_" & userName & "-" & ComputerType}
set newFolderPOSIX to POSIX path of (newFolder as text)
end tell
do shell script "rsync -zaP ~/" & space & quoted form of newFolderPOSIX & space & "--exclude='Library' --exclude='Public' --exclude='Applications'"