0

通知センターの背景を変更するアプリを作成したかったので、それをアップルスクリプトしました。誰かが私のコードの何が問題なのか教えてください。

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
4

1 に答える 1

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
于 2012-12-25T19:46:30.957 に答える