2010-02-05 53 views
0
defaults write com.apple.finder AppleShowAllFiles ON 

現在,它的工作原理如何使用Applescript訪問Finder中的隱藏文件?

tell application "Finder" to get folder ".spring" of home 
#folder ".spring" of folder "username" of folder "Users" of startup disk of application "Finder" 

...

defaults write com.apple.finder AppleShowAllFiles OFF 

現在不

tell application "Finder" to get folder ".spring" of home 
#Can’t get folder ".spring" of folder "username" of folder "Users" of startup disk of application "Finder" 

我需要將文件複製到該位置。

回答

2

如果可能,我會在這種情況下避免Finder。 do shell script應該能夠做你想做的。

tell application "Finder" 
    set fileToMove to choose file 
    set targetPath to "~/.spring" 
    set moveCmd to "mv '" & (POSIX path of fileToMove) & "' " & targetPath 
    do shell script moveCmd 
end tell 
+0

使用bash是醜陋的,但我想它是有效的。我希望你可以做一些像「告訴finder獲取隱藏文件」或其他系統事件的技巧。 – Pepijn 2010-02-07 16:50:13

+0

確實如此,但我發現通常使用Applescript是最可靠的方法。在這種情況下,Finder會明確禁止看到不可見的文件(通過隱藏的'defaults'設置),因此無法訪問該文件夾似乎是API設計者所期望的。 – 2010-02-08 18:54:44

相關問題