Does Applescript Finder update still exist

(Lenny Eiger) #1

I’m having lots of fun. I have a script that takes down a Helix database, makes some backups, runs it thru a checking utility and brings it back up again. Iv’e been using for years, its installed at 6 client sites. Was solid for a long time, now a bit flaky.

I am getting some errors, mostly -609 and even a -43. I quit out of the database app, want to make a copy of the database file (basic duplicate) and it can’t find the file? when I have given it the full file location as an alias?

Do I need to add extra delays or a tell Finder ‘update the enclosing folder’? Does that even work these days?

TIA. Lenny

(Shane Stanley) #2

You shouldn’t. In fact, it’s probably not a good idea under 10.13.

But Finder scripting has become slower and more painful; if you can avoid it, I suggest you do.

(Lenny Eiger) #3

Shane, thanks for responding.
I have a construct that was failing (in 13.3 and other earlier OS’es). It puts together a string of text (theString) and then there is an “if exists file theString”.
There was clearly no file in the location with that name. It kept giving me a true in the condition… until I put a “update mainLocation” command (already inside a tell Finder block) right before the if exists. Then it properly returned a false for that condition.
That’s where the -43 was coming from - it was trying to duplicate a non-existent file. Go figure.
Now I just have to solve that -609, but tis driving another app…

(Shane Stanley) #4

I’d skip the Finder for that, and use:

 theString as alias
-- it exists if you get here
on error
 -- it doesn't exist
end try

(Lenny Eiger) #5

This has been working intermittently. I have a clients machine running 10.12.6. I used this construct to see if a hard drive was mounted. If it fails, I mount it.

This is the salient stuff:

tell application “System Events”
set mountedFolderThere to false
set mountedFolder to (mountedFolder as alias)
set mountedFolderThere to true

then there’s the on error, etc. All that works fine. mountedFolder is a property at the top of the script, not an alias, just a string (never changes). Plain AppleScript.

This works great all day long, checks every 5 mins… If I unmount the remote drive it recovers perfectly. However, after restarting the computer, it fails to fail on the set the variable to an alias step. It goes for two or three iterations before it actually mounts, 10 mins or so. It still never reports an error, or goes into the error condition.

I’m wondering if the machine (a MacProCylinder) is doing everything else before it actually does its mount. Any ideas?

(Shane Stanley) #6

I’m not sure I have anything to add, other than questioning why you have a System Events tell block there.