tags:

views:

138

answers:

1
defaults write com.apple.finder AppleShowAllFiles ON

Now it works

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

Now it doesn't

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"

I need to copy a file to that location.

+1  A: 

I would avoid the Finder in this case if possible. do shell script should be able to do what you want.

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
Thomas Brice
Using bash is ugly, but I suppose it works. I hoped you could do a trick like "tell finder to get hidden file" or something with system events.
Pepijn
indeed it is, but I find that oftentimes with Applescript it is the most reliable way to do it. In this case, the Finder is explicitly prohibited form seeing invisible files (via that hidden `defaults` setting) so it seems that its inability to access the folder is what the API designers intended.
Thomas Brice