我想创建一个应用程序来更改通知中心的背景,以便使用它。有人请告诉我我的代码有什么问题。
set NCBGPath to "/System/Library/CoreServices/Notification Center/Contents/Resources/"
set NCBackground to "linen.tiff"
set themeFolder to (choose folder with prompt "Choose a Theme") as text
set themePath to themeFolder & NCBackground
set posixNCPath to NCBGPath & NCBackground
set shouldCopy to false
tell application "Finder"
if exists file themePath then set shouldCopy to true
end tell
if shouldCopy then
do shell script "cp " & quoted form of POSIX path of themePath & space & quoted form of posixNCPath with administrator privileges
-- you probably should correct the file permissions too as the copied file probably won't have the proper owner and stuff
else
display dialog "Could not find the background file in the chosen folder."
end if
答案 0 :(得分:0)
可能这样:“如果cp检测到尝试将文件复制到自身,则副本将失败。”
如果将最后一个if语句更改为:
,会发生什么if shouldCopy then
do shell script "cp " & quoted form of POSIX path of themePath & space & quoted form of NCBGPath with administrator privileges
-- you probably should correct the file permissions too as the copied file probably won't have the proper owner and stuff
else
display dialog "Could not find the background file in the chosen folder."
end if