Slow Finder update of text files

I’m using Shane S’s write_to_file handler to write files to a volume on a drive connected to my laptop via USB. After running the App it may take 5-10 minuets for the files to appear on the volume in the Finder.

Is there a way to speed this up?
(MacBook Pro 10.14.5)
Thanks

You can try adding code like this:

use AppleScript version "2.5" -- macOS 10.11 or later
use framework "Foundation"
use framework "AppKit"
use scripting additions

current application's NSWorkspace's sharedWorkspace()'s noteFileSystemChanged:pathToFolder

But there does seem to be an issue with the Finder catching up. You might want to read this thread:

What I am seeing is that the finder window is updated in a batch every 4-5 minutes with the most current file shown/updated between 4-5 minuets old from the time updated. After the app stops, everything is updated in about 10 minutes.

noteFileSystemChanged was depreciated after 10.6?

I am able to read a file that has just been written but not visible in the Finder.

The noteFileSystemChanged method was, but noteFileSystemChanged: was not. I’ve seen some references to the fact that it needs to be run from the main thread, so running it in an editor probably won’t do anything. I suppose you could try it this way:

current application's NSWorkspace's sharedWorkspace()'s performSelectorOnMainThread:"noteFileSystemChanged:" withObject:pathToChangedItem waitUntilDone:true

Does pressing command-shift-. make them show up?

After my last post the volume I was using succumbed to corruption and had to be reinitialized. Luckily I had copied my files to another volume.

When I ran the program again to the volume with the already collected files, the files were being updated every five seconds and at the end of said update was current.

When I ran the program in SD and pressed the CMD-SHIFT-PERIOD the files were updated immediately.

I had accumulated over 200,000 files in the folder to which I was writing the files. I think that was at least part of the issue (corrupted volume maybe another factor).

I wrote a program which created a tree of folders. I appended the original app to write files to only the roots folders of the tree. I then copied the 200,000 files from the earlier program to the volume with the tree (outside of the tree). I haven’t had time to collect such a number of files yet but there is no visible delay (as of yet) with the Finder displaying the file as it is written.

Didn’t try noteFileSystemChanged:.

Thanks for the update. I know that in testing scripts I’ve sometimes accidentally written thousands of files where I didn’t mean to (and where I shouldn’t!). It happens so fast, it’s easy not to notice.