如何使用Applescript访问Finder中的隐藏文件?

时间:2010-02-05 16:16:17

标签: applescript

defaults write com.apple.finder AppleShowAllFiles ON

现在可行了

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"

我需要将文件复制到该位置。

1 个答案:

答案 0 :(得分: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