Force folder list refresh?

Hi:

I create and save a bunch of files in a folder, most overwriting an existing file. When I open the folder in list view and sort by date, for example, they don’t sort to the top. I can see the correct modify time, but none re-sort unless I actually click on the file or move the cursor onto it to select it in list view.

Does anyone know the fastest method to reliably force a folder/file refresh, and the correct sort, via script? This lack of accurate, updated information of what’s in folders seems to be system-wide and is extremely frustrating. I even seem to have folder actions that don’t get triggered when something new is added to a folder.

OS X 10.3.5.

Thanks,

guy o.

To refresh:

tell application "Finder" to update alias "path:to:dir:"

To choose a sort column:

tell application "Finder"
	set sort column of list view options of front window to modification date column
end tell

Hi jj:

Thanks, I see that in the dictionary. However, I can’t get it to work in any way.

If I’m looking at a window, how can I get its path, so I can use your syntax? I’ve spent about an hour using every permutation of window and container to no avail.

Thanks,

guy o.

Try this:

set dir to alias "path:to:dir:"

tell application "Finder"
	set sort column of list view options of window of dir to modification date column
	open dir
end tell

Hi:

Thanks again, that works. However, the folder is hard-coded in the example. Do you know how to get the path to the active Finder window? Then I could use it on any folder.

Thanks,

guy o.

This should operate on the front Finder window.

tell application "Finder"
	try
		set sort column of list view options of front window ¬
			to modification date column
	on error e
		display dialog e buttons {"OK"} default button 1 with icon 0
	end try
end tell

– Rob

Hi:

Thanks, Rob, but my question is not how to sort the frontmost window, but how to get its path so I can refresh its info with the “update” command. Any help is appreciated.

Thanks,

guy o.

Does this work?

tell application "Finder"
	if (count windows) is not 0 then
		try
			update items of front window
		on error e
			display dialog e
		end try
	end if
end tell

– Rob

Hi:

Thanks Rob, that does work!

guy o.

I empathize with guy o. on the very slow updating of the Finder windows and with the responsiveness of Folder Actions. I have several Folder Action scripts that run on a Server and I am continually fiddling with the file objects to get the Folder Action scripts to activate and do thier job. These same scripts I have attempted as idle scripts but the “System Events” and/or “Finder” are still slow and sometimes they (“System Events” and/or “Finder”) crash for no reason. This then creates hidden files that are in use and cannot be deleted and the original file object is locked, causing the scripts to fail because the file cannot be manipulated in any way. Quiting “System Events” and/or “Finder” and other applications that may have a hold on the file object do not free up the file and the hidden file either. Restart of the server is the only answer. I shouldn’t have to restart the server several times a day just to get a file freed for processing.
I may be just venting, but there has to be a way of getting a responsive update of file objects.